Ben328 has asked for the wisdom of the Perl Monks concerning the following question:
Here's a log from an application and i wanted to be able to parse anything after "INFO -" till the date in next line as one varibale. You can see each line is similar till "INFO -" then the last portion is all over the place.
2012-09-14 16:55:22,498 ACTIVE ExecuteThread: '8' for queue: 'weblogic.kernel.Default (self-tuning)' (com.this.perl.seems.kinda.Cool:di sconnectCORBA:154) INFO - Well this is just one line text
2012-09-14 16:55:22,498 ACTIVE ExecuteThread: '8' for queue: 'weblogic.kernel.Default (self-tuning)' (com.this.perl.seems.kinda.Cool:di sconnectCORBA:154) INFO - Well this is just multiple line text
With formats Like this
***** Some other text **** then some more text on another line
2012-09-14 16:55:22,498 ACTIVE ExecuteThread: '8' for queue: 'weblogic.kernel.Default (self-tuning)' (com.this.perl.seems.kinda.Cool:di sconnectCORBA:154) INFO - Well once again this is part starts with bracket and blah blah blah
Well i tried to write this program where I was able to exactly match upto "INFO -" but the last variable matches single line and not multiple lines. I tried added \ms but that didn't help. Can we not say match everything from here on out till you match my first varible of date in next line ? Basically ask the last varible to match everything in the line till it sees next date.Any help in right direction would be much appreciated.
while ( $line = <> ) { if ($line =~ m/^(\[\d\d\d\d[-]\d\d[-]\d\d \d\d[:]\d\d[ +:]\d\d[,]\d\d\d\]) (\[\S+\]) (\S+) (\'\d\d?\d?\') (\S+ \S+) (\'.*\') +(\(.*\)) (\S+) ([ -]) (.*)/) { print $1; print $2; print $3; print $4; print $5; print $6; print $7; print "$8 "; print "$9 "; print "$10 \n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Can't seem to match from one varibale to next one.
by tobyink (Canon) on Sep 16, 2012 at 18:45 UTC | |
by Ben328 (Novice) on Sep 16, 2012 at 19:24 UTC | |
by kcott (Archbishop) on Sep 17, 2012 at 06:35 UTC | |
by Ben328 (Novice) on Sep 19, 2012 at 22:39 UTC | |
by tobyink (Canon) on Sep 17, 2012 at 08:54 UTC | |
|
Re: Can't seem to match from one varibale to next one.
by Kenosis (Priest) on Sep 16, 2012 at 21:54 UTC | |
by Ben328 (Novice) on Sep 16, 2012 at 22:52 UTC | |
by Kenosis (Priest) on Sep 17, 2012 at 00:08 UTC |