go ahead... be a heretic | |
PerlMonks |
Bug in substitution operator?by polettix (Vicar) |
on Jan 10, 2009 at 20:15 UTC ( [id://735426]=perlquestion: print w/replies, xml ) | Need Help?? |
polettix has asked for the wisdom of the Perl Monks concerning the following question:
Hi all,
I'm bothering you only to ask if this behaviour is what's actually expected (and why, of course): The fact is that: is being interpreted as $1{whatever}, i.e. the value corresponding to the whatever key in hash $1, instead of the value of $1, followed by the string {whatever}. This particular behaviour is a consequence of the unlucky usage of the substitution part delimiters, i.e. {} braces. Should we use another one this would not be triggered, i.e. the following works like a charm (note the square brackets instead of braces in the substitution part): So, it seems that the escape character \ is being used to allow for embedding braces into braces. But this is not needed at all, as we can see from the following: Perl is perfectly happy with the unescaped braces inside the substitution part, even when this very part is delimited by braces. Both 5.8.8 and 5.10.0 show the same behaviour. In my view it seems to be a bug; thoughts? perl -ple'$_=reverse' <<<ti.xittelop@oivalf Io ho capito... ma tu che hai detto?
Back to
Seekers of Perl Wisdom
|
|