laziness, impatience, and hubris | |
PerlMonks |
Re: Re: Re: variable set to 0 ? 0 : 1by abell (Chaplain) |
on Sep 06, 2002 at 08:06 UTC ( [id://195595]=note: print w/replies, xml ) | Need Help?? |
Nice golf, but your solution never returns 0, which is what the original snippet does. Furthermore, if $status is '0E0' or '0.0' it returns 1, because they both are true values, though numerically zero.
See:
prints out 0 0 0 0 0 0 0.0 1 0 0E0 1 0 1 1 1 1 1 1 Best regards Antonio Bellezza Update: As pointed out in other posts, the same behaviour of "0.0" and "0E0" is true for strings not representing numbers, which have true values, but behave as 0 in numeric comparison. The difference is a warning of type Argument "xyz" isn't numeric in numeric eq (==) at - line 3.when -w is enabled.
In Section
Seekers of Perl Wisdom
|
|