Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Perl's Warn and Die Signals

by Adam (Vicar)
on Jan 11, 2001 at 12:11 UTC ( #51097=perltutorial: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    $SIG{__WARN__} = sub
    {
    ...
        print STDOUT "Warning generated at line $loc[2] in $loc[1]:\n", @_
    +, "\n";
        return 1;
    };
    
  2. or download this
    use warnings FATAL => qw( all );
    
  3. or download this
    $SIG{__WARN__} = sub { CORE::die "Warning:\n", @_, "\n" };
    
  4. or download this
    use Carp;
    sub CallStack
    ...
        shift @stack for 1..3; # Cover our tracks.
        return wantarray ? @stack : join "\n", @stack;
    }
    
  5. or download this
    sub Something
    {
    ...
      # catch
      HandleEvalError( $@ ) if $@;
    }
    
  6. or download this
    BEGIN{ $SIG{__DIE__} = \&FatalErr }
    
    # Real problem if compile fails before getting here.
    sub FatalErr { # do stuff, maybe print @_ or something.
    }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perltutorial [id://51097]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2014-09-22 05:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (180 votes), past polls