in reply to Text::ParseWords parse_line containing quote

Can you clarify what it is you wish to accomplish?

I assume you're not just looking for space-separated words, for which split(' ', $string) would be sufficient...

Do you want to ignore single quotes, but treat double-quoted phrases as a single token?

Without knowing this, it's hard to identify the correct solution...

  • Comment on Re: Text::ParseWords parse_line containing quote

Replies are listed 'Best First'.
Re: Re: Text::ParseWords parse_line containing quote
by LanceDeeply (Chaplain) on Jul 24, 2003 at 19:01 UTC
    I want to use parse_line because of it's nifty parsing of embedded tokens. I am not looking for a split solution. I will be passing different delimiters, and strings into parse_line.

    For this case, I want my output to be:

    [it] [can] [do] [this] [but] [it] [can't] [do] [this]
    instead of just
    [it] [can] [do] [this]

      The quote characters are hard-coded into the operation of parse_line. There's no argument or switch that lets you tell it that you want double-quotes and back-slash escapes to recognized, but to treat single quotes as regular characters.

      It looks like the only way to do what you want is to copy-and-paste the source code for sub parse_line into your script or module, and then go through and remove the ' characters from the key regexes -- for instance, changing "' to ".