in reply to Re^2: unless versus if ( ! ) inside a subroutine
in thread unless versus if ( ! ) inside a subroutine
You have to understand that Perl will return the last evalution from a sub if you are not explicit. So start being explicit!sub testUnless { my $v = 'Navidson'; unless ( $v ) { return undef; } else { return $v; } } sub testIfNot { my $v = 'Holloway'; if (!$v) { return undef; } else { return $v; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: unless versus if ( ! ) inside a subroutine
by Wheeler (Acolyte) on Jan 15, 2008 at 18:20 UTC | |
|