Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
Brother Kozz,
You have committed no sins, you're soul is clean. Looking at Text::Parsewords, the reqex is kinda of hairy and doesn't handle the case you've thrown at it. (my numbers)
1. while (length($line)) { 2. ($quote, $quoted, undef, $unquoted, $delim, undef) = 3. $line =~ m/^(["']) # a $quote 4. ((?:\\.|(?!\1)[^\\])*) # and $quoted text 5. \1 # followed by the same quote 6. ([\000-\377]*) # and the rest 7. | # --OR-- 8. ^((?:\\.|[^\\"'])*?) # an $unquoted text 9. (\Z(?!\n)|(?-x:$delimiter)|(?!^)(?=["'])) # plus EOL, delimiter, or quote 10. ([\000-\377]*) # the rest 11. /x; # extended layout 12. return() unless( $quote || length($unquoted) || length($delim));
In your case, we fail the first part of the regex (lines 3-5) because we only have a single quote. We also fail the second part of the regex (lines 8-10) because we do start with a quote. Since we've failed the match, $quote is undef, $unquoted is undef and $delim is undef. As a result of them all being undef, an empty list is returned.
Maybe some of the more regex-y inclined brothers can think of a replacement regex. It hurts me just to read the ones like this.
-derby

In reply to Re: Text::ParseWords by derby
in thread Text::ParseWords by Kozz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others pondering the Monastery: (18)
    As of 2014-10-23 19:19 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      For retirement, I am banking on:










      Results (128 votes), past polls