@parts = split m{ " # if we match a quote (?{ ++$x }) # increment quote counter (?!) # and fail | \s+ # or if we match whitespace (?(?{$x&1}) # if $x is odd (?!) # fail ) # (otherwise succeed) }x, q{A B "C D" E F"G H" I}; #### @parts = $string =~ m{ (?=\S) # so long as there's something ahead of us: [^\s"]* # non-quotes non-whitespace (?: " [^"]* " # a quoted part [^\s"]* # non-quotes non-whitespace )* # zero or more times }xg;