I still don't understand why eval { } || 0 did not work though
eval doesn't affect warnings. And the warning occurred during the division, not after the eval was completed.
>perl -we"my $x; my $q = eval { $x / 4 } || 0; Use of uninitialized value in division (/) at -e line 1. >perl -we"my $x; my $q = eval { ($x||0) / 4 }; >perl -we"my $x; my $q = ( $x / 4 ) || 0; Use of uninitialized value in division (/) at -e line 1. >perl -we"my $x; my $q = ( ($x||0) / 4 );
In reply to Re^6: eval not working the way I expected?
by ikegami
in thread eval not working the way I expected?
by convenientstore
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |