Perl-Sensitive Sunglasses | |
PerlMonks |
Re^3: Print not printingby mrpeabody (Friar) |
on Jun 24, 2005 at 19:20 UTC ( [id://469804]=note: print w/replies, xml ) | Need Help?? |
Well, they're more special than "the variables sort() happens to use". To achieve that handy usage without warnings, Perl exempts $a and $b from declaration checks under strict vars. That means that perl -we'use strict; $a = 5; print $a' compiles and runs without errors, while perl -we'use strict; $c = 5; print $c' won't even compile. This has bitten me in real life when trying to cut down a test case for closure scoping behavior. My real code was doing different things than my one-liners, and there was NO DIFFERENCE except the variable names. I was tearing my hair out. $a and $b are naturals for quick throwaway code; the documentation uses them in examples all over the place. However, $c and $d are much better choices. I find myself completely avoiding $a and $b outside of sort(), just to be on the safe side.
In Section
Seekers of Perl Wisdom
|
|