in reply to Interpolating Nursery Rhyme
Hmm... you don't use quotes with numbers. '5' and "5" are the same thing-- a string containing the character '5'. If it's in quotes of any sort, it's a string.
One uses single quotes for strings of literal text. So:
prints "Bar is $bar".my $bar = 3; my $foo = 'Bar is $bar'; print $foo, "\n";
One uses double quotes for strings that should have variables interpolated. So:
prints "Bar is 3".my $bar = 3; my $foo = "Bar is $bar"; print $foo, "\n";
So maybe this rhyme can help:
:)For literal strings, quote with Single. (Isn't this a silly jingle?) Interpolation uses Double. Forget this rule, you'll be in trouble.
stephen
In Section
Perl Poetry