use warnings; use strict; MAIN: { my $qc = q{"}; # quoting character my $quoted_body = qr{ [^$qc\\]* (?: \\. [^$qc\\]* )* }xms; while () { my (undef, undef, undef, $time, $data1, $data2) = m{ $qc ($quoted_body) $qc }xmsg; print "time: <$time> data1: <$data1> data2: <$data2> \n"; } } __DATA__ example.txt "unimportant1" "unimportant2" "unimportant3" "timeA" "data1A" "data2A" other.txt "ignore1" "ignore2" "ign\"ore3" "timeB" "data1B" "dat\"a2B" foo.txt "ignore1" "" "ign\"ore3" " timeC " "" "dat\"a2C"