die 
die LIST
dieOutside an eval, this function
prints the concatenated value of LIST to
STDERR and exits with the current
value of $! (the C library’s errno variable). If $! is 0, it exits with the value of ($? >> 8), the status of the last reaped
child from a system, wait, close
on a pipe, or `command`. If ($? >> 8) is 0, it exits with
255.
Within an eval, the function
sets the $@ variable to the error
message that would have otherwise been produced, then aborts the
eval, which returns undef. The die function can thus be used to raise named
exceptions that can be caught at a higher level in the program. See
eval later in this chapter.
If LIST is a single object reference,
that object is assumed to be an exception object and is returned
unmodified as the exception in $@
(described below).
If LIST is empty and $@ already contains a string value (typically
from a previous eval) that value is
reused after appending “\t...propagated”. This is useful for
propagating (reraising) exceptions:
eval { ... };
die unless $@ =~ /Expected exception/;If LIST is
empty and $@ already contains an
exception object, that object’s $@–>PROPAGATE
method is invoked with additional file and line number parameters
to determine how the exception
should propagate, with its return value replacing the value in $@.
That is, it’s as if $@ = eval {
$@–>PROPAGATE(_ _FILE_ _, _ _LINE_ _) } were
called.
If LIST is empty ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access