in reply to Re^4: Elegant way to return true or nothing from a subroutine?
in thread Elegant way to return true or nothing from a subroutine?

In the section "Returning Failure," PBP recommends using a bare return to signify failure. There is a two page discussion there, explaining that, at the hands of the caller, the returned undef can easily turn into the one-element list (undef) and evaluate to true.
sub foo { return undef;} sub bar { return;} if (my @foos = foo()) { print "foo() is so true...\n"; ## surprise! } else { print "foo() is false.\n" } if (my @bars = bar()) { print "bar() is true...\n"; } else { print "bar() is false.\n" }