NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Single quoted variable (Score:2)
is "$french_for{'$num'}", 'un', 'single quoted variable key';
Will fail. You've single quoted '$num' hence you're looking for the key "\$num".
Re:Single quoted variable (Score:2)
Yes, that's the failure, but I don't know why that should be obvious because if you add diag "'$num'" to the end of that script, you get this:
In other words, a variable in single quotes will interpolate if it's embedded in a double quoted string but not used as the key to a hash or an index into an array. That seems a bit odd and it would be nice if it were documented better. I should submit a patch for perltrap if it's not documented.
Re:Single quoted variable (Score:2)
Reply to This
Parent