use Regexp::Common; my $re = qr/ ( \w+ | $RE{quoted} ) \s+ => \s+ ( \w+ | $RE{quoted} ) ,? /x; /$re/ and print "$1: $2\n" while ; __DATA__ key => 44, "key" => "fun. \"yes\" 'fun'", 'key' => 'yahoo\' "fun"'