Perl-Sensitive Sunglasses | |
PerlMonks |
How to delete a file with a print statementby Ovid (Cardinal) |
on Jul 31, 2006 at 16:30 UTC ( [id://564791]=perlmeditation: print w/replies, xml ) | Need Help?? |
Despite what you might be thinking, I'm not talking about printing to a filehandle. However, whileI was trying to help a coworker understand variable interpolation in strings, I came up with the following code:
The "$french_for{'$num'}" doesn't work because, as hv explained on P5P: A variable access is parsed as code. "'$num'", the variable being accessed is $num; in "$french_for{'$num'}", the access is to: $french_for{'$num'} which is a nonexistent hash element. I'm not sure what behaviour you were expecting instead, but I've never noticed anyone stumble on this before. And this allowed me to come up with this:
Note that "foo.bar" is now gone. Frankly, I think you'd have to jump through a few hoops to create a security hole here, but I thought it was interesting. Cheers, New address of my CGI Course. Formating fixed by Me
Back to
Meditations
|
|