From: Ilya Zakharevich Date: Sat, 20 Jun 1998 15:36:14 +0000 (-0400) Subject: applied patch, with edits to the prose X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=55602bd2172c61544e9cd65d2a79174a7fbb4bf4;p=p5sagit%2Fp5-mst-13.2.git applied patch, with edits to the prose Message-Id: <199806201936.PAA17499@monk.mps.ohio-state.edu> Subject: [PATCH 5.004_67] Error variables compared p4raw-id: //depot/perl@1179 --- diff --git a/pod/perlvar.pod b/pod/perlvar.pod index 1a12011..d10fe35 100644 --- a/pod/perlvar.pod +++ b/pod/perlvar.pod @@ -448,6 +448,8 @@ Under VMS, the pragma C makes C<$?> reflect the actual VMS exit status, instead of the default emulation of POSIX status. +Also see L. + =item $OS_ERROR =item $ERRNO @@ -463,6 +465,8 @@ to C<$!> to set I if, for instance, you want C<"$!"> to return the string for error I, or you want to set the exit value for the die() operator. (Mnemonic: What just went bang?) +Also see L. + =item $EXTENDED_OS_ERROR =item $^E @@ -490,6 +494,8 @@ via C<$!>. Caveats mentioned in the description of C<$!> generally apply to C<$^E>, also. (Mnemonic: Extra error explanation.) +Also see L. + =item $EVAL_ERROR =item $@ @@ -503,6 +509,8 @@ Note that warning messages are not collected in this variable. You can, however, set up a routine to process warnings by setting C<$SIG{__WARN__}> as described below. +Also see L. + =item $PROCESS_ID =item $PID @@ -869,3 +877,54 @@ See L, L and L for additional info. =back + +=head2 Error Indicators + +The variables L<$@>, L<$!>, L<$^E>, and L<$?> contain information about +different types of error conditions that may appear during execution of +Perl script. The variables are shown ordered by the "distance" between +the subsystem which reported the error and the Perl process, and +correspond to errors detected by the Perl interpreter, C library, +operating system, or an external program, respectively. + +To illustrate the differences between these variables, consider the +following Perl expression: + + eval ' + open PIPE, "/cdrom/install |"; + @res = ; + close PIPE or die "bad pipe: $?, $!"; + '; + +After execution of this statement all 4 variables may have been set. + +$@ is set if the string to be C-ed did not compile (this may happen if +C or C were imported with bad prototypes), or if Perl +code executed during evaluation die()d (either implicitly, say, +if C was imported from module L, or the C after +C was triggered). In these cases the value of $@ is the compile +error, or C error (which will interpolate C<$!>!), or the argument +to C (which will interpolate C<$!> and C<$?>!). + +When the above expression is executed, open(), C<>, and C +are translated to C run-time library calls. $! is set if one of these +calls fails. The value is a symbolic indicator chosen by the C run-time +library, say C. + +On some systems the above C library calls are further translated +to calls to the kernel. The kernel may have set more verbose error +indicator that one of the handful of standard C errors. In such cases $^E +contains this verbose error indicator, which may be, say, C. On systems where C library calls are identical to system calls +$^E is a duplicate of $!. + +Finally, $? may be set to non-C<0> value if the external program +C fails. Upper bits of the particular value may reflect +specific error conditions encountered by this program (this is +program-dependent), lower-bits reflect mode of failure (segfault, completion, +etc.). Note that in contrast to $@, $!, and $^E, which are set only +if error condition is detected, the variable $? is set on each C or +pipe C, overwriting the old value. + +For more details, see the individual descriptions at L<$@>, L<$!>, L<$^E>, +and L<$?>.