in reply to Re^2: unless versus if ( ! ) inside a subroutine
in thread unless versus if ( ! ) inside a subroutine

How about trying explicit returns?
sub testUnless { my $v = 'Navidson'; unless ( $v ) { return undef; } else { return $v; } } sub testIfNot { my $v = 'Holloway'; if (!$v) { return undef; } else { return $v; } }
You have to understand that Perl will return the last evalution from a sub if you are not explicit. So start being explicit!

Replies are listed 'Best First'.
Re^4: unless versus if ( ! ) inside a subroutine
by Wheeler (Acolyte) on Jan 15, 2008 at 18:20 UTC
    The question is not on recommended practices to fix a problem but rather the perl internals regarding if and unless.
    A reply falls below the community's threshold of quality. You may see it by logging in.