Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

traceback on error

by incognito129 (Acolyte)
on Feb 22, 2010 at 02:19 UTC ( [id://824563]=perlquestion: print w/replies, xml ) Need Help??

incognito129 has asked for the wisdom of the Perl Monks concerning the following question:

One of the things I like about python, is that when a script exits cause of an error, it spits out a traceback. I'm wondering is there anyway of getting a perl script to do this as well?

Replies are listed 'Best First'.
Re: traceback on error (confess)
by tye (Sage) on Feb 22, 2010 at 03:43 UTC

    As I mentioned in the CB when you asked there, use Carp:

    $SIG{__DIE__}= sub { require Carp; Carp::confess(@_); };

    - tye        

Re: traceback on error
by zwon (Abbot) on Feb 22, 2010 at 04:24 UTC

    Also, you can use Carp::Always. Start your script like this:

    perl -MCarp::Always script.pl
    and it will print backtrace if program die.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://824563]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2025-03-20 02:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When you first encountered Perl, which feature amazed you the most?










    Results (60 votes). Check out past polls.