13/17

8. Error Handling (Chapter 13)

  • Throw exceptions. Don't return magic values. People don't check them anyway.

  • croak and carp are useful for throwing exceptions.

  • For complicated exceptions, use Exception Classes.

  • Use the standard Fatal module to make the builtins return exceptions; for example:

        use Fatal qw( open close );
        open my $fh, '>', $filename;
        print {$fh} $results;
        close $fh