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
  • PrintPrint
Share this Page URL
Help

Chapter 16. Some Advanced Perl Techniques > Trapping Errors with eval

16.1. Trapping Errors with eval

Sometimes, your ordinary, everyday code can cause a fatal error in your program. Each of these typical statements could crash a program:

    $barney = $fred / $dino;         # divide-by-zero error?

    print "match\n" if /^($wilma)/;  # illegal regular expression error?

    open CAVEMAN, $fred              # user-generated error from die?
      or die "Can't open file '$fred' for input: $!";


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

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

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint