eweibust has asked for the wisdom of the Perl Monks concerning the following question:
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:And get:print 'Testing\z'; print 'Testing\\n'; print 'Testing\\\n'; print "\n";
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 Testing\nTesting\nTesting\\n erikweibust@daleweibust ~/perl/lrn_perl $
Can anybody help clear this up? Thanks, Erikerikweibust@daleweibust ~/perl/lrn_perl $ ./test1-2.pl TestingnTesting\nTesting\n erikweibust@daleweibust ~/perl/lrn_perl $
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Problem w/ single-quoted strings
by bassplayer (Monsignor) on May 13, 2004 at 18:47 UTC | |
by eweibust (Initiate) on May 13, 2004 at 19:56 UTC | |
by bassplayer (Monsignor) on May 14, 2004 at 05:36 UTC | |
Re: Problem w/ single-quoted strings
by Stevie-O (Friar) on May 13, 2004 at 21:46 UTC | |
by eweibust (Initiate) on May 14, 2004 at 18:23 UTC | |
Re: Problem w/ single-quoted strings
by nmcfarl (Pilgrim) on May 13, 2004 at 21:25 UTC | |
by nmcfarl (Pilgrim) on May 13, 2004 at 21:37 UTC |
Back to
Seekers of Perl Wisdom