in reply to I know...again multiline match!
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( 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 }
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... }
|
|---|