in reply to What Are The Rules For Subs And Modules When Fed Wrong Input
and then, in my_submy ($value,$error) = my_sub(input => 'who', inny => 'what'); unless ($value) { my_abort ("There was an error: ",$error); }
As you can see, with this you can test for each input requirement by name, dieing on the "gotta-have-its" and just warning on the "ok-I-dont-need-its".sub my_sub { my %args = { input => undef, inny => undef, @_ }; return(undef,"Missing inny") unless $args->{'inny'}; # do some stuff if ($problem) { return(undef,$error_msg); } return($value,undef); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: What Are The Rules For Subs And Modules When Fed Wrong Input
by bcisys (Initiate) on Jul 25, 2002 at 16:57 UTC |