Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 11. Warnings > Item 102. Use Carp to get stack traces

Item 102. Use Carp to get stack traces

If your code is going to die or emit a warning, it’s nice if it can give you as much information as possible about what is going on at the time of the failure. One of the most valuable pieces of information is the call stack. Unfortunately, Perl’s built-in die and warn functions don’t provide that information.

Here’s a series of subroutines that call randomly_fail, and some of them call each other. When you run this program, you don’t know where it will fail.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial