mikejones has asked for the wisdom of the Perl Monks concerning the following question:
As another idea, what about setting__DATA__ msgagt=ESM_WMB_AIX,sec_id=Sec _id,severity=Low,node=test,msgnode=qwmbap01.xxxxxxxxxxxxx.net,utc=2007 +-04-26 18:01:59.472+00:00,om=UID=3a7affd6-f420-11db-80b1-000000000000 +,AlertCod e=AEM001,AlertType=AEM-default,AppName=AEM-CommonService2,Message=5004 +:An error has been reported by the BIPXML4C component.:XML __CODE__ 1 use strict; 2 use warnings; 3 #use diagnostics; 4 use Data::Dumper; 5 6 my $ovo = qq(/home/mikej/out); 7 my $msgagt = qr/(?:\w+\=\w+)/; #|(?:\w+=\{.*?\}))/; 8 my ($key,$value); 9 my (%HoA,@HoA); 10 11 open (my $out, "+<", $ovo) or die "file '$ovo' was not opened $!"; 12 13 while (<$out>) { 14 s/^\s+|\s+$//g; ## rid of newlines at begin and end 15 chomp; 16 next unless length $_; ## skip blanks 17 s/^'|'\w+|'.*?$//; ## rid of ticks and ticks plus metachars +\w 18 s/\x7b|\x7d//g; ## rid of { and } 19 ($key,$value) = (split /=/, $_, 0); 20 #print "KEY:\t",$key,"\n"; 21 #print "VALUE:\t",$value,"\n"; 22 #push @{$HoA{$key}}, $value if (/$msgagt/g); 23 print "$_\n" if (/$msgagt/g); 24 } 25 #for my $i (sort keys %HoA) { 26 # print "$i -- @{ $HoA{$i} }\n"; 27 #}
local $/ = ',';
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: key value pair or simply a regexp
by thezip (Vicar) on May 18, 2007 at 20:26 UTC | |
by mikejones (Scribe) on May 18, 2007 at 20:43 UTC | |
by mikejones (Scribe) on May 18, 2007 at 22:33 UTC | |
by jdporter (Paladin) on May 21, 2007 at 14:59 UTC | |
|
Re: key value pair or simply a regexp
by jdporter (Paladin) on May 18, 2007 at 19:15 UTC | |
by mikejones (Scribe) on May 18, 2007 at 19:46 UTC | |
|
Re: key value pair or simply a regexp
by FunkyMonk (Bishop) on May 18, 2007 at 21:57 UTC | |
|
Re: key value pair or simply a regexp
by duff (Parson) on May 18, 2007 at 18:40 UTC | |
by mikejones (Scribe) on May 18, 2007 at 19:26 UTC |