Perl in a Nutshell

Perl in a NutshellSearch this book
Previous: Reference: deleteChapter 5
Function Reference
Next: Reference: do
 

die

die message

Prints message to the standard error output and exits the Perl program with a nonzero exit status. message can be a list value, like the arguments to print, from which the elements are concatenated into a single string for output. If message does not end with a newline (\n), the current script filename, line number, and input line number (if any) are appended to the message with a newline. With no argument, the function outputs the string Died as its default.

die exits the programs with the current value of the $! variable, which contains the text describing the most recent operating system error value. This value can be used in the message to describe what the problem may have been.

die behaves differently inside an eval statement. It places the error message in the $@ variable and aborts the eval, which returns an undefined value. This use of die can raise runtime exceptions that can be caught at a higher level of the program.


Previous: Reference: deletePerl in a NutshellNext: Reference: do
Reference: deleteBook IndexReference: do

Library Navigation Links

Copyright © 2001 O'Reilly & Associates. All rights reserved.