[prev] [index] [next]

Terminating

Normal termination: call exit 0 at the end of the script.

The die function is used for abnormal termination:

  • accepts a list of arguments
  • concatenates them all into a single string
  • appends file name and line number
  • prints this string
  • and then terminates the Perl interpreter
Example:

if (! -r "myFile") {
    die "Can't read myFile\n";
}
# or
die "Can't read myFile\n" if (! -r "myFile");

Convention: omit parentheses on die argument list if just one argument