Hi all,
I'm trying to create a regex that will select multiple lines of text into an array, the regex starts with a keyword and then the end marker is a blank line. So far I have...
@data is the read in log file that I'm trying to parse and extract from. My problem is that the blocks of text vary in the number of lines so counting on from the matching line will not work, but counting back from the end marker of a blank line will.
if($data[$i] =~ /Message Type: /){
$j=$i+13; #This will not work
$k=$i+14; #This will not work
@details0=split / /, $data[$i];
@details1=split / /, $data[$j];
@details2=split / /, $data[$k];
$txname=$details0[2];
$txtime=$details2[2];
$errorcode=$details1[2];
print OUT "$txname\t\t\t$txtime\t\t$errorcode\n";
}
Many many thanks from a rapidly balding chap in advance,
Beeny
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.