Hello,
I've searched high and low for the answer to my problem, but I've yet to see an example that addresses what I am trying to do. I am hoping that you can help..
Basically, I am reading in a file that in filled with multiple-line log entries. The first line of each log entry has the date (amongst other items) in it in the mm/dd/yyyy format. This Perl script is launched via a web form when a person provides the date that they'd like to search through the logs for (via a dropdown menu on the webpage). If the date that the user requests matches the date in the logfile, it should print everything from that first matching line until the very end of the file. The log is set up in such a manner that the day that the person is requesting will always be the latter portion of the file.
With this in mind, here's the code block in question:
LINE: while ($currentfile=<FILE>) {
if ($currentfile =~ /^[0-9][0-9][0-9][0-9][0-9][0-9]/){
$match_date = substr($currentfile,52,10);
if ($search_date eq $match_date) {
print RESULTS "$currentfile";
do {
next LINE;
print RESULTS "$currentfile";
} until eof();
} #if search_date
} # if $currentfile
}
}
One other note, the reason that I am trying to match on that particular reg ex is because the first line of each log entry (which also includes the date in mm/dd/yyyy format) begins with a six digit sequence number (with leading zeroes).
Thanks very much in advance for any guidance!
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.