Something like this, possibly...
while( my $line = <FILE> . <FILE> ) {
chomp $line; # gets rid of the trailing \n
# on second line to allow $ on
# the regex below.
$line =~ /^(\d{4}-\d{2}-\d{2}).*-{5}\s\S*?\s(\S*)\s(.*)$/;
my ( $day, $message, $type ) = ( $1, $2, $3 );
# do what you need to with these
}
This assumes that the '-----' and 'AuthAPI' are fixed words in your log file, since, at least in the case of '-----', that helps to skip past the date and other information at the start of line 1. If AuthAPI is not necessarily fixed, but the message (0x00003e3f in this case) is the last thing on line 1, then the following will work...
while( ( $line1 = <FILE> ) && ( $line2 = <FILE> ) ) {
chomp $line1;
chomp $line2;
$line1 =~ /^(\d{4}-\d{2}-\d{2}).*\s(.*)$/;
my ( $date, $message, $type ) = ( $1, $2, $line2 );
# continue on...
}
Dr. Michael K. Neylon - mneylon-pm@masemware.com
||
"You've left the lens cap of your mind on again, Pinky" - The Brain
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.