Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This noncompliant code example tries to open a file, and invokes the obsolete die() method if it fails.

Code Block
bgColor#ffcccc
langperl
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
bgColor#ccccff
langperl
use Carp;

my $file;
open(FILE, "<", $file) or croak "error opening $file: stopped";
# work with FILE

...