Chapter 6. EXCEPTIONS AND ERROR TRAPPING

Error trapping and handling is a necessary part of all programming. There are many different specific reasons for trapping an error, but they basically come down to two basic reasons:

  1. Avoiding doing something that would cause the program/application to fail at a later stage. For example, checking that we've opened a file correctly before we start writing to it.

  2. Letting the user know when something has happened that either you didn't plan on or expect. For example, suddenly running out of disk space.

The model used by Perl is borrowed heavily from the C and shell script methods of checking the results of function calls. This presents some problems when dealing with certain errors, and also makes propagating ...

Get Perl To Python Migration now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.