Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re: Or, Or, Equals Zero, $x ||= 0by FunkyMonk (Chancellor) |
on Nov 27, 2007 at 23:24 UTC ( [id://653415]=note: print w/replies, xml ) | Need Help?? |
$x ||= 42 is read as "if $x is false (empty string, 0 or undef) store 42 into $x". This construct has always had problems when used to assign a default value (what if you want $x to be zero) that will soon be solved by the "defined-or" operator, //, arriving soon in perl 5.10.0.
In Section
Seekers of Perl Wisdom
|
|