in reply to Parsing a Log file
If so, just read in your log file in blocks of 20 lines, put each line in an array and check $array[9]=~m/IC--E/. If this is true, print "@array[5, 15]\n";Perhaps it can look like this:
use strict; while (1) { my @array; foreach (1..20) { my $line = <DATA>; chomp $line; push @array, $line; } print "@array[5, 15]\n" if $array[9]=~m/IC--E/; last if eof; } __DATA__ 1 Software Package: "xxxxxxx" 2 Operation: install 3 Mode: not-transactional,not-undoable | force 4 Time: XXXXXXX 5 ================= 6 WORKSTATION1: 7 8 Distribution ID: `xxxx.xxx' 9 10 Current software package status is 'IC--E'. 11 12 Operation successful. 13 14 Execution of user program 'during_install - C:\Staging\MS07-061_WXP +_ENU.1.0.1.0\setup.exe (/s)' completed with result: 'success'. 15 16 User program exit code: 0 17 18 19 ================= 20 21 Software Package: "XXXXX" 22 Operation: install 23 Mode: not-transactional,not-undoable |force 24 Time: XXXXXX 25 ================= 26 WORKSTATION2: 27 28 Distribution ID: `XXXXX.XXXX' 29 30 Current software package status is 'IC--E'. 31 32 Operation unsuccessful. 33 34 Execution of user program 'during_install - C:\Staging\MS07-061_WXP +_ENU.1.0.1.0\setup.exe (/s)' completed with result: 'success'. 35 36 User program exit code: 0 37 38 39 =================
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
|
|---|