From:                   Pete Emerson <[EMAIL PROTECTED]>
> 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

What about :

push @str, (defined $1 ? $1 : $2) 
        while ($string =~ s/^(?:""|"(.*?[^\\])"|(\S+))\s*//);

# !!! Destroys the $string !!!

This code allows you to escape the doublequote by a backslash.

Jenda

=========== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==========
There is a reason for living. There must be. I've seen it somewhere.
It's just that in the mess on my table ... and in my brain.
I can't find it.
                                        --- me

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

Reply via email to