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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.