Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Problem w/ single-quoted strings

by nmcfarl (Pilgrim)
on May 13, 2004 at 21:25 UTC ( #353214=note: print w/replies, xml ) Need Help??


in reply to Problem w/ single-quoted strings

I don't know about clear it up, but it looks to me that the text and the behavior do not match. The text more clearly describes what happens in quoted strings, not what happens in single quoted strings as this example shows:

print '\ \\ \\\ \\\\ \\\\\ '; print "\n"; print "\ \\ \\\ \\\\ \\\\\ "; print "\n";
result:
\ \ \\ \\ \\\ \ \ \\ \\

As you can see in the quoted string "\ " displays a space while in the single quotes it displays itself. Thus the backslash does not appear to always be an exception to the every char stands for itself rule. What it stands for appears to depend on what follows it. And sometimes it appears to stand for itself.

perl, v5.8.1-RC3 built for darwin-thread-multi-2level

Replies are listed 'Best First'.
Re: Re: Problem w/ single-quoted strings
by nmcfarl (Pilgrim) on May 13, 2004 at 21:37 UTC

    Ok if you read perlop manpage under q/STRING/ 'STRING' you will find that it perfectly describes what is happening:

    ' A backslash represents a backslash unless followed by the delimiter or another backslash, in which case the delimiter or backslash is interpolated.'

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2023-02-08 03:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (40 votes). Check out past polls.

    Notices?