in reply to Re: How to return an appropriate error from module?
in thread How to return an appropriate error from module?
Is there any rule/praxis for or against setting $@ inside my modules or subroutines -- as a way of returning error messages?
If using above example as a guide, would the following module be considered to be "kosher" perl?
package Phone; sub prettify { local ($_) = @_; return eval { /^$/ and die "No number\n"; # do something to modify $_ here $_; }; }
In my main program this could then be called using:
my $pretty_number = Phone::prettify($number) if (not defined($pretty_number)) { # e.g. insert message $@ into web page output }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: How to return an appropriate error from module?
by ikegami (Patriarch) on Mar 06, 2009 at 16:25 UTC |