...
This noncompliant code example tries to open a file, and invokes the obsolete die() method if it fails.
| Code Block | ||||
|---|---|---|---|---|
| ||||
my $file; open(FILE, "<", $file) or die "error opening $file: stopped"; # work with FILE |
...
This compliant colution uses the croak() function instead of die().
| Code Block | ||||
|---|---|---|---|---|
| ||||
use Carp; my $file; open(FILE, "<", $file) or croak "error opening $file: stopped"; # work with FILE |
...