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"
-
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.