Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I have a question regarding the Text::ParseWords module, which is standard with the latest versions of Perl. I've studied the perlman page on this module, but am still confused why it seems to "break" in my test-case. Here's what I wanted to do:
use Text::ParseWords; my $heredoc =<<END_OF_HEREDOC; The Text::ParseWords module is the most recent module with which I've struggled. END_OF_HEREDOC my @words = quotewords('\s+', 0, $heredoc); foreach(@words){ print $_ . "\n"; }
The problem seems to be that it outputs NOTHING ; no words at all. And the root of the problem lies in the single apostrophe in the string which is part of a conjuction. But if I escape the single-quote by putting a backslash in front of it, then everything is output fine. I could use a regex to place backslashes in front of apostrophes, but are these the only characters that cause this problem? Am I not quite using this module correctly? It seems silly to have to escape the characters -- why won't it just work?

In reply to 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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2024-04-24 07:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found