Can we not say match everything from here on out till you match my first varible of date in next line ?
Yes, but only if all of your data is in a single string. As tobyink pointed out, if you're reading your log file line-by line, e.g.:
... while ( $line = <> ) ...
and you've just read the first line of a multiline record, you can't match against the next record's date.
Although tobyink provided an excellent solution, if you don't have an enormous log file, the following option may also help with your situation, as it reads the entire log file into a variable for processing:
logFile.txt:
[2012-09-14 16:55:22,498] [ACTIVE] ExecuteThread: '8' for queue: 'webl +ogic.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: 'webl +ogic.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: 'webl +ogic.kernel.Default (self-tuning)' (com.this.perl.seems.kinda.Cool:di + sconnectCORBA:154) INFO - Well once again this is part starts with b +racket and blah blah blah
Script:
use strict; use warnings; my @infos; { local $/; open my $fh, '<', 'logFile.txt' or die $!; my $data = <$fh>; push @infos, $1 while $data =~ /INFO - (.+?)(\[\d{4}|\Z)/gs; } chomp @infos; print join "\n--##--\n", @infos;
Output:
Well this is just one line text --##-- Well this is just multiple line text With formats Like this ***** Some other text **** then some more text on another line --##-- Well once again this is part starts with bracket and blah blah blah
Unless I'm mistaken, you're interested in grabbing the text after the "INFO" in each record. In the script above, @infos will contain that text, and the regex grabs it by matching as you've described, and includes matching on the last line where no date follows.
Hope this helps!
In reply to Re: Can't seem to match from one varibale to next one.
by Kenosis
in thread Can't seem to match from one varibale to next one.
by Ben328
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |