On 1/26/06, JupiterHost.Net <[EMAIL PROTECTED]> wrote:
snip
> Without trying to sort out the hair ball of code might I recommend
> simplifying you condition?
>
>
> my $ftp = Net::FTP->new(...) or _my_die('Connection failed: ' .
> Net:FTP->message());
>
> $ftp->login($user, $pass) or  _my_die('Login failed: ' . $ftp->message());
>
>
> _my_warn('foo is bar') if $foo eq $bar;
>
> sub _my_croak {
>      my ($msg) = @_;
> # put $msg in a file, db, email, whatever
>      croak $msg;
> }
>
> sub _my_carp {
>      my ($msg) = @_;
> # put $msg in a file, db, email, whatever
>      carp $msg;
> }
snip

The problem with defining your own versions of die, warn, croak, and
carp is that only your code uses them.  If another module croaks or
dies then your custom error handling is not used.  This is why we have
access to $SIG{__DIE__} and $SIG{__WARN__} (croak() and carp()
internally use die() and warn() respectivly if I remember correctly).

A quick search of CPAN turned up the Religion module (which I remember
as being a joke module, but seems to have morphed into something
useful) that makes the process of chaining signal handlers together a
little cleaner (I used a closure in my example).

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to