while () { my ( $msg ) = ( /msg=(.*?) Src \d+ / ); # do something with $msg... } #### while () { next unless ( s/^([\d-]+)\s+([\d:]+)\s+(\S+)\s+// ); chomp; my ( $date, $time, $ws2k ) = ( $1, $2, $3 ); # remainder of log string contains an IP addess followed by # a set of "key=value string " tuples of various sizes my ( $ip, %flds ) = split /\s+(\w+)=/; # parens keep key strings in split output # do stuff with %flds and other vars... }