Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Cody,

One of the things I use to get around things like this is to use anonymous hashes to call subroutines. For example:
my ($value,$error) = my_sub(input => 'who', inny => 'what'); unless ($value) { my_abort ("There was an error: ",$error); }
and then, in my_sub
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); }
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".
The my_abort could even be changed to check for error severity and do a warn or die based on that.

Anyhow, just my 2 cents on handling sub calls that may return errors.

What does this little button do . .<Click>; "USER HAS SIGNED OFF FOR THE DAY"

In reply to Re: What Are The Rules For Subs And Modules When Fed Wrong Input by tame1
in thread What Are The Rules For Subs And Modules When Fed Wrong Input by Cody Pendant

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2024-04-19 06:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found