![]() |
|
Your skill will accomplish what the force of many cannot |
|
PerlMonks |
A somewhat unexpected side effect...by blazar (Canon) |
on Nov 21, 2006 at 11:40 UTC ( #585235=perlmeditation: print w/replies, xml ) | Need Help?? |
Although a documented one... basically I just want to report an interesting entry in the Journal of DAxelrod (who is also a fellow monk here), at use Perl. To cut it short, the following:
outputs
whereas if you uncomment line 9, it will issue a
warning, and output num:1 let:aawhich is as of the subject, surprising and unexpected due to the fact that $num is just used, but appearently not modified in any way whatsoever. However, as the original article itself says this is both documented and useful for obfu. In this respect I was thinking that a particularly confusing effect could be achieved if one used e.g. "9" instead of "z", but that doesn't seem to be the case:
B::Concise seems to say the same for both:
(Note: damn! I couldn't use | diff z - under Windows.) Fortunately, this is perfectly well documented as well: The auto-increment operator has a little extra builtin magic to it. If you increment a variable that is numeric, or that has ever been used in a numeric context, you get a normal increment. This obviously mean that "that is numeric" comprises "that looks like a number". How much it may resemble one, though, is not very intuitive. I do know it's more or less Perl's standard behaviour, but I for one would expect the string to be treated as a string in both of the following:
Back to
Meditations
|
|