home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


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.