![]() |
|
Perl: the Markov chain saw | |
PerlMonks |
Don't get too cute about modifying and using @_ in the same line of codeby aufflick (Deacon) |
on Aug 23, 2012 at 07:18 UTC ( #989223=perlmeditation: print w/replies, xml ) | Need Help?? |
Update: Darn - it's back. Completely ignore the below meditation, instead to post a question! This is a rehash of a stack-overflow answer I just made. I hope that's not against modern Perlmonks etiquette! I recently got an odd error in some code that definitely worked before: Can't upgrade BIND (1) to 9 at Foo.pm line 999Google told me only that someone had seen the same error in a cgi once. How I fixed it might be instructive although I'm still not exactly sure what it means. The code, that worked in some calling circumstances but not others, was a simple method forwarding method that looked a little like this:
It's a little lazy, sure, but according to perl's left to right evaluation, it should (and usually was) the equivalent of this:
I'm guessing that since @_ is, under some circumstances, a special way of accessing the stack and, under other circumstances, a fairly regular global list, the way in which the method was called was hitting different code paths. Moral of the story - don't get too cute about modifying and using @_ in the same line of code!
Back to
Meditations
|
|