Aimee Cardenas wrote:
Ok, All,

Hello,

I'm a little confused. How does your outputs from die and print differ when you put either $! or $? at the end of the statement? I've been using $! at the end of my die statements and am afraid that I've been unknowingly not using the correct syntax because my code never dies!

$! and $? are just variables like any other variables that you may create and use in your program and as such they have no effect on whether die() or print() will work or not.


Would someone explain the difference between these two?

perldoc perlvar
[ SNIP ]
    $CHILD_ERROR
    $?      The status returned by the last pipe close, backtick ("``")
            command, successful call to wait() or waitpid(), or from the
            system() operator.  This is just the 16-bit status word
            returned by the traditional Unix wait() system call (or else
            is made up to look like it).  Thus, the exit value of the
            subprocess is really ("$? >> 8"), and "$? & 127" gives which
            signal, if any, the process died from, and "$? & 128"
            reports whether there was a core dump.  (Mnemonic: similar
            to sh and ksh.)

            ... etc.
[ SNIP ]
    $OS_ERROR
    $ERRNO
    $!      If used numerically, yields the current value of the C
            "errno" variable, or in other words, if a system or library
            call fails, it sets this variable.  This means that the
            value of $! is meaningful only immediately after a failure:

            ... etc.



John
--
The programmer is fighting against the two most
destructive forces in the universe: entropy and
human stupidity.               -- Damian Conway

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to