...
If any error occurs, the program calls the croak() function, passing it a string that includes both the source file being opened and the $! variable, which contains a system error string based on the value of errno, which is set to a useful value when the open(2) or close(2) functions fail.
Exceptions
EXP32-EX1EX0: If the return value is inconsequential or if any errors can be safely ignored, such as for functions called because of their side effects, the function's return value may be silently discarded.
EXP32-EX2EX1: The autodie module is designed to replace functions that return a value indicating failure with functions that throw an exception on failure. When autodie is in use, any functions it redefines may be safely ignored.
| Code Block | ||||
|---|---|---|---|---|
| ||||
use autodie; my $source; open(SOURCE, "<", $source); @lines = (<SOURCE>); close(SOURCE); |
EXP32-EX3EX2: Functions that send data to standard output or standard error need not have their return values checked. This includes print and printf, but only if their filehandle argument is not supplied, or is explicitly set to *STDOUT or *STDERR. If they send their output to any other filehandle, their return value must be checked.
...