in reply to Bug with Carp and $!/$?

I'm not sure what seems weird to you, the Perl error message or the printing of the number 255. If the former, it's not a bug: $? refers to the error message of a child process which you did not spawn before printing it. So although you explicitly set the variable, I am not terribly surprised that Perl complained and you didn't get the value of $? printed out. As for the 255, I *think* that I vaguely remember (how's that for a disclaimer) mention on this site of Perl (or was it Carp specifically?) defaulting to octal 255 in some situations, but uselessly enough, I can't recall anything of the context of that thread, others I'm sure can enlighten both of us.

Replies are listed 'Best First'.
Re: Re: Bug with Carp and $!/$?
by Kageneko (Scribe) on Jul 10, 2003 at 17:34 UTC
    Oh, I expected to get the value of $! (which I set to 10). The reason I set $? is that the 'die' manpage states:

    Outside 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.

    I was trying to make sure that $? would be non-zero, although it just occurred to me that I should've done something like: $? = (9 << 8) in order for that to work.