I'd probably go for the regex just because it's the first thing I thought of and I didn't consider your problem for too long (hey, at least I'm honest :). But this should do:
my @tokens = $string =~ /([^ ]+".*?"|[^ ]+)/g;
Update: Forgot you could have something before the first quote.
antirice
The first rule of Perl club is - use Perl
The ith rule of Perl club is - follow rule i - 1 for i > 1
In reply to Re: Not quite a simple split
by antirice
in thread Not quite a simple split
by John M. Dlugosz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |