in reply to Parsing a Log file
You can use an input record separator of =================\n to read the log in more meaningful chunks. split can split the chunks into lines. Then you'll be interested in lines 0 (workstation), 4 (status) and 10 (exit code) of each chunk. Check for the specified status using m//, the match operator, and print if there's a match using an array slice.
$/ = "=================\n"; while ( <DATA> ) { my @lines = split /\n/; next unless $lines[4] =~ /'IC--E'/; print "@lines[0, 10]\n"; }
update: Slightly clearer(?) logic:
$/ = "=================\n"; while ( <DATA> ) { my @lines = split /\n/; print "@lines[0, 10]\n" if $lines[4] =~ /'IC--E'/; }
|
|---|