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


in reply to regex to split on ' ', but skip spaces inside quotes

Rather than thinking in terms of "splitting on spaces", may be it would work better if you thought in terms of "gather the things I want". For instance, would this work for you:

#!/usr/bin/perl use strict; use warnings; my $string = q(hi my name is 'john doe'); my @parts = $string =~ /'.*?'|\S+/g; print map { "$_\n" } @parts; __END__
?