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"; } }

In reply to 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.