in reply to Preferred Error notification?

sub myfunc { my $arg1 = shift or (die|warn) "missing arg in myfunc"; }

die or warn based on severity of missing argument. But that's just me.

--
perl -e "print qq/just another perl hacker who doesn't grok japh\n/"
simeon2000|http://holdren.net/

Replies are listed 'Best First'.
Re: Re: Preffered Error notification?
by ChemBoy (Priest) on Aug 05, 2002 at 18:07 UTC

    I'd say that this is precisely the situation that Carp is designed for--use carp or croak rather than warn and die, and they'll know which invocation of the function they messed up, which is generally fairly useful information.

    Alternatively, set $@, return undef, and let the caller figure out the problem. :-)



    If God had meant us to fly, he would *never* have given us the railroads.
        --Michael Flanders

      I rarely return undef explicitly, as it tends to do the wrong thing in list context. return by itself is shorter and smarter.