Ok, I'm going to assume that you have something like:
my $ftp = Net::FTP->new( ... ) or die $!;
And you don't feel like dying, you just want to say 'Hey, this thang ain't workin'.
Well, here's one solution:
my $ftp = Net::FTP->new( ... );
if ( defined $ftp ) {
$ftp->func1( ... );
$ftp->func2( ... );
$ftp->quit;
} else {
warn "Hey, this thang ain't workin! $!\n";
}
or, another way to do it might be to create a SIG handler... although I'm not fond of it personally:
$SIG{__DIE__} = sub { warn shift and exit };
my $ftp = Net::FTP->new( ... ) or die $!;
That's kinda gracefull, but it will quit your process... another solution could be:
sub ftp_stuff {
my $ftp_ref = shift;
$ftp_ref->func( ... );
$ftp_ref->quit;
}
my $ftp = Net::FTP->new ? ftp_stuff $ftp : warn $!;
I hope I've helped you out.
Enjoy!
--
Casey
|