I have just started learning Perl and this is my first Perl question. I'm working through "Learning Perl" and I've got a problem with strings. Specifically the difference b/t single-quoted and double-quoted strings and the use of the backslash character.
In the Single-quoted strings section it says that, "Any character other than a single quote or a backslash between the quote marks (including newline characters, if the string continues onto successive lines) stands for itself inside a string. To get a backslash, put two backslashes in a row, and to get a single quote, put a backslash followed by a single quote."
I tried the following:
print 'Testing\z';
print 'Testing\\n';
print 'Testing\\\n';
print "\n";
And get:
erikweibust@daleweibust ~/perl/lrn_perl $ ./test1-2.pl
Testing\nTesting\nTesting\\n
erikweibust@daleweibust ~/perl/lrn_perl $
So I'm scared that either the books wrong (please don't get the wrath of Randal Schwartz) or I'm missing something. I would have expected the output to be:
erikweibust@daleweibust ~/perl/lrn_perl $ ./test1-2.pl
TestingnTesting\nTesting\n
erikweibust@daleweibust ~/perl/lrn_perl $
Can anybody help clear this up?
Thanks,
Erik