in reply to Re^5: eval not working the way I expected?
in thread eval not working the way I expected?
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 );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: eval not working the way I expected?
by convenientstore (Pilgrim) on Jan 11, 2008 at 04:00 UTC | |
by parv (Parson) on Jan 11, 2008 at 05:14 UTC | |
by ikegami (Patriarch) on Jan 12, 2008 at 05:39 UTC | |
by tye (Sage) on Jan 12, 2008 at 06:34 UTC |