in reply to Parsing a Log file
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 } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Parsing a Log file
by polettix (Vicar) on Dec 16, 2007 at 22:42 UTC | |
by dsheroh (Monsignor) on Dec 17, 2007 at 06:19 UTC |