1. Please preview your question before you post it. The contents of your log file would be a lot easier to read if it was in a <pre> ... </pre> block. Update: Thanks for reformatting it.
2. What information do you want to extract from the log file? We need to know this in order to help you. Update: Okay, now I see what you want to parse.
Here's one way of doing it:
This assume that package status line precedes workstation line which precedes the exit message line.my $r; while (<>) { if (/^Current software package status is: *(.*)/) { $r->{package_status} = $1; } elsif (/^(WORKSTATION\d+):/) { $r->{workstation} = $1; $r->{workstation_line} = $. } elsif (/^(User program exit code: .*)/) { $r->{exit_message} = $1; $r->{exit_line} = $. # process $r if ($r->{package_status} eq "IC--E") { print "$r->{workstation}(line $r->{workstation_line}) $r->{exit_ +message}(line $r->{exit_line}) } $r = {}; # clear variables for next record } }
In reply to Re: Parsing a Log file
by pc88mxer
in thread Parsing a Log file
by nashkab
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |