while (<$fh> ) {
if ( $_ =~ /$eot/ ) {
last;
} else {
$_ = <$fh>;
$item = $_;
$item =~ s/\n//gs;
$item .= "\n\n";
}
if ( $item =~ /$errmsg/ ) {
push @erritems, $item;
}
}
Maybe I'm just missing something too, and I certainly don't understand the structure of your data file, but here's what I understand of the code fragment above:
-
read a
line | paragraph;
-
test if the
line | paragraph has an $eot match and exit the loop (and error log processing) if so;
-
if the
line | paragraph is not an $eot match, throw it away and read the next line | paragraph from the file (update: which is not tested for an $eot match);
-
do some newline massaging on the
line | paragraph;
-
push the (massaged)
line | paragraph to the @erritems array if it is an $errmsg match.
What I don't understand is why you're throwing away half the
lines | paragraphs in the file up to the point of the
$eot line | paragraph match.
Update: I just noticed you're reading the file in paragraph mode
$/ = '<table align="left" border="0" cellspacing="0" cellpadding="1"';
and so changed all instances of line(s) to paragraph(s).
Give a man a fish: <%-{-{-{-<
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.