in reply to Re: Re: using exit and number 1 at end of file
in thread using exit and number 1 at end of file
If you neglect overloading, all values other than "0", "", (), or undef are true. Equality to zero has nothing to do with it. Consider these:
With overloading, it is even possible to get an object which is both not equal to zero and false.my @zeroes = qw( zero 0ButTrue 00 ); for my $z (@zeroes) { print "'$z' ", $z == 0 ? 'is ' : 'is not ', "equal to zero.\n"; print "'$z' ", $z ? 'is ' : 'is not ', "true.\n\n"; }
package C; use overload 'bool' => sub { 0 }; use overload '==' => sub { 0 }; sub new { bless {} } package main; my $c = C->new; print "\$c is not equal to zero.\n" unless $c == 0; print "\$c is not true.\n" unless $c;
-sauoq "My two cents aren't worth a dime.";
|
|---|