Re: use of uninitialized value....



On 1/26/06, JupiterHost.Net <mlists@xxxxxxxxxxxxxxx> 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).
.



Relevant Pages

  • Re: why not die?
    ... > sub write_log { ... > It doesn't die or print any error even $log did not exist. ... Whenever you suspect that Perl is not seeing your script the same way ... print(LOG $msg); ...
    (perl.beginners)
  • Re: MsgBox basics
    ... Sub Message_box_test ... Response = MsgBox ... MsgBox "You clicked cancelled" ... Dim Msg As String ...
    (microsoft.public.excel.programming)
  • Re: Probleme beim Debuggen
    ... XLstatus xlstatus; ... wenn MSG nicht gleich der Vorhergehenden ... Public Sub CallbackCAN(ByRef msg As CanMessage, ... End Sub ...
    (microsoft.public.de.vb)
  • Re: Auto Run a Macro
    ... Private Sub Worksheet_SelectionChange(ByVal Target As Range) ... Sub ConfirmSelection() ... Dim Msg As String ...
    (microsoft.public.excel.programming)
  • RE: value in combo box
    ... Dim rs As DAO.Recordset ... I had the wrong key feild value PID now when i give it the correct ProjectID ... if rs.nomatch only than should i get the msg displayed. ... Private Sub cmbpno_AfterUpdate ...
    (microsoft.public.access.formscoding)