There's more than one way to do things | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
That's how I used to do it in C/C++ before it had a bool type, when it was necessary to canonize the value.
If that's too idiomatic, using return asbool($status) where that's an inlined function would be readable and just as efficient. Note that it does a bit more than it does in a stronly-typed language. What if $status is not an int at all? The normal boolism is to treat undef and empty strings as false, also, and in one known case 0e1 is used as zero-but-true. The original test will be different from that; the !! idiom preserves it. —John In reply to Re: Re: Re: variable set to 0 ? 0 : 1
by John M. Dlugosz
|
|