That interpolates @peteyorn as an array.
In which version of Perl? I get an error with 5.14 as I expect, because the single-quote in It's looks like the end of string quote marker.
Is there a way to really, truly, literally, verbatim assign what's enclosed, no questions asked and no thoughts thunk on perl's part?
No. That's a semi-predicate problem and is unsolveable. You can read text via IO though.
| [reply] [d/l] [select] |
It's Oh. That was foolish of me not to notice. Thank you.
That's a semi-predicate problem and is unsolveable.
What is semi-predicate? It sounds theoretical.
In which version of Perl?
This is perl, v5.10.1 (*) built for i486-linux-gnu-thread-multi
You can read text via IO though.
Is that what onelesd is talking about? Is it in man perlio?
| [reply] [d/l] [select] |
What is semi-predicate? It sounds theoretical.
What is google? semi-predicate -> http://en.wikipedia.org/wiki/Semipredicate_problem
Simply it means return undef to signal failure, but it can return undef as valid value, so you can't differentiate between failure or just a valid value
It applies here because perl expects perl syntax, so you can't inline arbitrary text verbatim as part of a perl program, it could be a perl program, so you have to quote/escape, like
my $asCloseAsYouCanGet = <<'__TO_VERBATIM__';
other stuff not that is not __TO_VERBATIM__ on a single line
__TO_VERBATIM__
The text in $asCloseAsYouCanGet cannot contain __TO_VERBATIM__ on a single line as input, because __TO_VERBATIM__ on a single line is like the closing quote, it signals the end of the input, so it can't be valid input
In other words, the semi-predicate problem, it can't be both valid input and closing quote, it has to be one or the other, not both
Its like pictorial depictions of numbers, the symbol for the number one, 1, cannot be the same symbol for the number two, 1 , because you cannot tell when it means one or it means two
1 + 1 + 1 = 4? See the first 1 is really one, the second 1 is really two, and the last one is really 1 , which adds up to four
:) | [reply] [d/l] |
use strict ;
use warnings ;
print $_ while (<DATA>) ;
__DATA__
RT @peteyorn: @Starbucks Thanks for putting the Break Up album for sal
+e in your stores. \\ It's a great album! Nice work!
| [reply] [d/l] |
Thank you. Is the + something I should type in, or something incidental that came off your terminal?
| [reply] |
Is the + something I should type in, or something incidental that came off your terminal?
That + is related to your Display Settings, specifically code wrapping. Do not retype code, or even copy & paste from the node itself. Use the download link, which is there for that very reason.
| [reply] [d/l] [select] |
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.
| [reply] [d/l] [select] |