in reply to Re^2: unless versus if ( ! ) inside a subroutine
in thread unless versus if ( ! ) inside a subroutine
...the unless is explicitly not going to ever evaluate because the condition is predetermined to be false.
This doesn't make much sense to me. In both cases (if and unless) the conditional has to be evaluated. It's just that when the value isn't negated, the last thing evaluated is the value as is. When you request the negated value to be tested in the conditional, the negated value is the last thing evaluated. How else would you explain that the following returns 1?
sub testUnlessNot { my $v = ''; unless ( !$v ) {}; # returns 1 }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: unless versus if ( ! ) inside a subroutine
by halley (Prior) on Jan 16, 2008 at 14:02 UTC | |
by almut (Canon) on Jan 16, 2008 at 15:11 UTC |