Even simpler IMHO is to avoid double quoting anything that will not
need interpolating. I also use this as a quick visual clue
of where demons may hide ;-)
BTW, I didn't see the need for the "\r" in the print as in DOS\WIN32
the "\n" is really both CR and LF characters.
open OUT,'>C:\windows\foobar.txt';
print OUT "Ha!\n";
close OUT;
--
I'd like to be able to assign to an luser | [reply] [d/l] |
| [reply] |
See perldoc perlop, and look for "Quote and Quote-like Operators". \n is "virtual" with respects to Perl in that does not map to a single ASCII byte irrespective of OS. It assumes the OS's representation of a "newline". Under Unix, this is equivalent to \cJ. Under DOS/Windows, it's \cM\cJ. Likewise, I think \r behaves differently under MacOS as well, for the same reasons.
| [reply] [d/l] [select] |
print <<'' . " is the UNC name"
\\192.168.1.1
But this leaves an extra newline at the end of the IP
address. Am I missing something blatently obvious?
| [reply] [d/l] [select] |
In any quoted string ("", '', qq{}, q{}, etc.),
a double backslash must be interpolated as a single backslash, because a backslash is used to
escape the quoting character(s). This makes it possible to get the one character string \ and the two character string
\', with '\\\'' and '\\', respectively.
Here-docs are the exception to this. One can always find a terminator, possibly several characters long, that doesn't appear within the string itself. Thus, backslashes are free to be regular characters in a here-doc.
I don't think you're missing anything; this is just how strings work in Perl.
| [reply] [d/l] [select] |