http://www.perlmonks.org?node_id=128065


in reply to How can I split on a string except when inside quotes?

This doesn't handle all the subtle things (backslashes, single-quotes, etc) that Text::ParseWords does, but it works for the simple cases, and produces your expected output exactly (quotes intact): my @items = ($string =~ /(".*?"|\S+)/g);