Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Perl has a lot of quoting mechanisms...
See Quote-and-Quote-like-Operators

q{} is same as '' which means literal, no interpolation.

Update: Oh, I see what is going on....
If you use ' for the quoting character to delimit the string, then you have to escape the ' characters within the string.
The backslash character has a special meaning within q{}, but not within single quotes like: 'xxx'.
Normally you will have to "escape" the \ or the ' characters. That is because these characters have meaning as to when the TEXT starts and stops.

The alphabet of what is possible within the string is all possible characters. But the compiler has to know when the string starts and ends. In the program text (source code) there is no single character that definitively means: text starts and text stops, because all possible text characters can be part of the string.

There is a defined syntax to write a program literal in the source code. If you are not happy with those requirements (have to "escape" some characters), then I would make a config file and put the strings in there. Then they can be read as simply data. At the end of the day, a program statement is different than a line in a data file.

It is possible to use the HERE-DOC with a blank line terminator:

my $tweet2 =<<''; RT @peteyorn: @Starbucks sale in your stores. \\ It's a great album! +Nice work!;<p> print "before print\n"; print $tweet2; print "after print\n";
The RT @... @Starbuck... line appears verbatim, but you see even with that, we've made a special case, we stop when there is blank line. As an updated thought here...it is weird that: my $tweet2 =<<''; means stop on a blank line and I had to play around to verify what it did...<<'' does not mean "stop on no character".

There are syntax limitations when writing program code.
There are no limitations at all for characters in a data file.
If you cannot abide by the syntax limitations for program code, then put the data in a data file. And use a program to read that data.

Update as per OP's update:

de plus: my $tweet is just a particularly pesky example so I am coding against it. In the final application I will be piping a .csv through @ARGV, so will this problem just go away? (Some of the proposed solutions make me think so.)

Yes. Writing source code is different than reading data from a file.


In reply to Re: verbatim, non-interpolated assignment by Marshall
in thread verbatim, non-interpolated assignment by toro

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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 surveying the Monastery: (3)
    As of 2019-10-17 05:59 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Notices?