my (%hash,$count); for (@array) { # increase hash key $count++; # use 'x' quantifier to make it readable # I've made assumptions about data expected here # you may need to amend m/Packet ID (hex) \s+ (\S+) \s+ Origin \s+ (\S+)\s+ Date (mm/dd/yyyy) \s+ (\S+) \s+ Qualifier \s+ (\w+)\s+ Time \s+ (\S+) \s+ Terminal ID \s+ (\d+)\s+ Device ID (hex) \s+ (\w+) \s+ Application ID \s+ (\w+)\s+ Catalog Code \s+ (\w+) \s+ Function ID(hex) \s+ (\w+)\s+ Status \s+ (\d+) \s+ Severity \s+ (\d+)\s+ (.*)/x; $hash{$count}{'packet_id'} = $1; $hash{$count}{'origin'} = $2; $hash{$count}{'date'} = $3; $hash{$count}{'qualifier'} = $4; $hash{$count}{'time'} = $5; $hash{$count}{'terminal_id'} = $6; $hash{$count}{'device_id'} = $7; $hash{$count}{'application_id'} = $8; $hash{$count}{'catalogue_code'} = $9; $hash{$count}{'function_id'} = $10; $hash{$count}{'status'} = $11; $hash{$count}{'severity'} = $12; $hash{$count}{'error_message'} = $13; } # then run through and take action on hash for (keys %hash) { if ($hash{$_}{'error_message'} =~ /whatever/) { # do something ... } }
HTH
cLive ;-)
In reply to Re: Log File Parsing
by cLive ;-)
in thread Log File Parsing
by TStanley
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |