Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: verbatim, non-interpolated assignment

by Marshall (Abbot)
on Sep 14, 2011 at 02:49 UTC ( #925795=note: print w/replies, xml ) Need Help??

in reply to verbatim, non-interpolated assignment

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 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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://925795]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2019-10-16 21:37 GMT
Find Nodes?
    Voting Booth?