For all that we love about Perl, please, please, please check return values when calling functions and object methods. And if writing such code, please incorporate differing return values based upon execution success.
/me returns to code maintenance and debugging
use Fatal qw(:void open close);
open my $fh, $filename;
...
close $fh;
Re:Don't return undef
djberg96 on 2003-08-29T13:07:10
I had the same issue with Dave Cross' overloading article on perl.com. Relevant journal entry here.Re:Don't return undef
gav on 2003-10-03T03:27:28
I like to return undef. It means you can do stuff like:if (my $obj = Blah::Blah->fetch($foo)) {
$obj->bar;
}
Re:Don't return undef
pdcawley on 2003-10-16T12:04:09
But that's an 'interesting value' in this context. Fetch should return the requested object or undef, and throw an exception on any other kind of failure.