Home
Search Perl pages
Subjects
By activity
Professions, Sciences, Humanities, Business, ...
User Interface
Text-based, GUI, Audio, Video, Keyboards, Mouse, Images,...
Text Strings
Conversions, tests, processing, manipulation,...
Math
Integer, Floating point, Matrix, Statistics, Boolean, ...
Processing
Algorithms, Memory, Process control, Debugging, ...
Stored Data
Data storage, Integrity, Encryption, Compression, ...
Communications
Networks, protocols, Interprocess, Remote, Client Server, ...
Hard World Timing, Calendar and Clock, Audio, Video, Printer, Controls...
File System
Management, Filtering, File & Directory access, Viewers, ...
|
|
|
die LIST
Outside of an eval(), prints the value of
LIST to STDERR and exits with the current value of $! (errno). If $! is 0, exits with the value of
($? >> 8) (backtick `command` status). If ($? >> 8)
is 0, exits with 255. Inside an eval(), the error message is
stuffed into
$@ , and the eval() is terminated with the undefined value; this
makes die() the way to raise an exception.
Equivalent examples:
die "Can't cd to spool: $!\n" unless chdir '/usr/spool/news';
chdir '/usr/spool/news' or die "Can't cd to spool: $!\n"
If the value of
EXPR does not end in a newline, the current script
line number and input line number (if any) are also printed, and a newline
is supplied. Hint: sometimes appending ``, stopped'' to your message will
cause it to make better sense when the string ``at foo line 123'' is
appended. Suppose you are running script ``canasta''.
die "/etc/games is no good";
die "/etc/games is no good, stopped";
produce, respectively
/etc/games is no good at canasta line 123.
/etc/games is no good, stopped at canasta line 123.
See also exit() and warn().
You can arrange for a callback to be called just before the
die() does its deed, by setting the $SIG{__DIE__} hook. The associated handler will be called with the error text and can
change the error message, if it sees fit, by calling die()
again. See the perlvar manpage for details on setting %SIG entries, and eval() for some examples.
Source: Perl builtin functions Copyright: Larry Wall, et al. |
Next: do BLOCK
Previous: delete EXPR
(Corrections, notes, and links courtesy of RocketAware.com)
Up to: Current Process Control Up to: Error Handling and Logging
Rapid-Links:
Search | About | Comments | Submit Path: RocketAware > Perl >
perlfunc/die.htm
RocketAware.com is a service of Mib Software Copyright 2000, Forrest J. Cavalier III. All Rights Reserved. We welcome submissions and comments
|