i bet there's way of doing this on one line:
my $a = '"one two" three "four five six" seven eight nine';

my @ar = ($a =~ /((?:\"[^\"]*\"|[^\s]*))\s?/g); #should be possible to
remove "
s/\"//g foreach (@ar);

print "$_\n" foreach (@ar);

/Jon



Pete Emerson wrote:
> 
> I'd appreciate it if someone could help me wrap my brain around this one.
> I've got a string like this:
> $string='"one two" three "four five six"';
> 
> I'd like to wind up with an array like this:
> one two
> three
> four five six
> 
> Essentially, I would like to split up the string on spaces, but ignore spaces that 
>are
> inside pairs of quotes. So:
> $string='"one two" three "four five" six "seven eight nine"';
> should wind up as:
> one two
> three
> four five
> six
> seven eight nine
> 
> I've tried using a regular expression to replace "one two" with "one_two" and
> "one two three" with "one_two_three", thinking that then I could split on spaces
> and then strip out the _, but I didn't have any luck with that, either. Any pointers
> would be greatly appreciated.
> 
>         Pete
> 
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to