What we are trying to do is to scan a log file. It skips the old entries, and once it finds the first entry (such as line n) within the date/time range, it starts scanning the remaining file, including the first entry (line n) within the range. The following program does everything right except for one thing. It appears to skip the first entry (line n) that in the date/time range and scan only from the second line (line n+1). What change needs to be made to the program so it can start scanning from the first line (line n) that within the data/time range? Thank you in advance for your help and prompt reply!
# skip old entries:
while (<LOG>) {
if (/^\s*([\d\/\-]+\s+[\d\.\:]+)\s+/) {
next if ( (time() - str2time($1)) > $serverRef->{ScanErrlogLast
+Days}*24*3600 );
$ref->{start_check_datetime} = $1;
last;
}
}
# scan the entries:
while (<LOG>) {
…
The <LOG> has format like:
……
yyyy-mm-dd hh:mm:ss.nn xxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ; line n
yyyy-mm-dd hh:mm:ss.nn xxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ; line n+1
……
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.