in reply to Re: sub returning undef
in thread sub returning undef

What if () is valid? undef might be better off. i.e. a db error or data error might result in undef, where as if the subroutine runs to success, just there is no data, retunr undef.

Might be better to check for undef to see if an error occured? Just a thought.

Replies are listed 'Best First'.
Re: Re: Re: sub returning undef
by eclark (Scribe) on May 24, 2004 at 17:37 UTC

    It would be more appropriate to die on error, and expect the calling code to trap it using:

    eval { # calls go here }; if ($@) { # exception handling here }

        People who don't read the documentation (or ignore it) deserve their problems.