while( my $line = . ) { 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 = ) && ( $line2 = ) ) { chomp $line1; chomp $line2; $line1 =~ /^(\d{4}-\d{2}-\d{2}).*\s(.*)$/; my ( $date, $message, $type ) = ( $1, $2, $line2 ); # continue on... }