1use strict; 2use XML::Rules; 3 4my $parser = XML::Rules->new( 5 rules => [ 6 _default => 'content', 7 qr/^UBR\d+$/ => 'no content', 8 Mibs => 'pass no content', 9 ] 10); 11 12<<'*END*'; 13sdfgskdfh glsdfhg sldfhg sdfg 14sfgh 15 dfhgfhjgf hj 16*END* 17 18my $data = $parser->parse(\*DATA); 19 20use Data::Dumper; 21print Dumper($data); 22 23foreach my $ubr (keys %$data) { 24 print "$ubr: SNR=$data->{$ubr}{SNR} / SNRTotal=$data->{$ubr}{SNRTotal}\n"; 25} 26 27 28__DATA__ 29<?xml version="1.0" standalone="yes"?> 30<Mibs> 31 <UBR100000> 32 <SNRTotal>a</SNRTotal> 33 <SNR>b</SNR> 34 <CW_UNER>c</CW_UNER> 35 <CW_CORR>d</CW_CORR> 36 <CW_UNCORR>e</CW_UNCORR> 37 <FREQ>f</FREQ> 38 <OCUPACION>g</OCUPACION> 39 <MODCM>h</MODCM> 40 <MOD>i</MOD> 41 </UBR100000> 42 <UBR7200> 43 <SNRTotal>a</SNRTotal> 44 <SNR>b</SNR> 45 <CW_UNER>c</CW_UNER> 46 <CW_CORR>d</CW_CORR> 47 <CW_UNCORR>e</CW_UNCORR> 48 <FREQ>f</FREQ> 49 <OCUPACION>g</OCUPACION> 50 <MODCM>h</MODCM> 51 <MOD>i</MOD> 52 </UBR7200> 53</Mibs>