...
| Code Block | ||
|---|---|---|
| ||
my $source; open(SOURCE, "<", $source) or diecroak "error opening $source: $!"; @lines = (<SOURCE>); close(SOURCE) or diecroak "error closing $source: $!"; |
If any error occurs, the program calls the diecroak() 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.
...