$! ????

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

  In IO/Socket.pm is find things like $!, suggesting that
$! is a hash.  But in perlvar there's no indication of this:

       $!      If used numerically, yields the current value of
               the C "errno" variable, with all the usual
               caveats.  (This means that you shouldn't depend on
               the value of $! to be anything in particular
               unless you've gotten a specific error return indi­
               cating a system error.)  If used an a string,
               yields the corresponding system error string.  You
               can assign a number to $! to set errno if, for
               instance, you want "$!" to return the string for
               error n, or you want to set the exit value for the
               die() operator.  (Mnemonic: What just went bang?)

               Also see "Error Indicators".

  What gives?



Sent from a spam-bucket account; I check it once in a blue moon.  If
you still want to e-mail me, cut out the extension from my address,
and make the obvious substitutions on what's left.

Re: $! ????

KKramsch wrote:

Quoted text here. Click to load it

It's not.  Of course it's not.  It can't be.  $whatever can only be a
scalar.  But %! is a hash, and it'll be accessed by saying

Quoted text here. Click to load it

Perhaps looking up the variable you're actually dealing with
would've helped.  It was right under $!...

 %!      Each element of "%!" has a true value only if $! is
             set to that value.  For example, $! is true
             if and only if the current value of $! is "ENOENT";
             that is, if the most recent error was "No such file
             or directory" (or its moral equivalent: not all
             operating systems give that exact error, and
             certainly not all languages).  To check if a
             particular key is meaningful on your system, use
             "exists $!"; for a list of legal keys, use
             "keys %!".  See Errno for more information, and also
             see above for the validity of $!.

Quoted text here. Click to load it

             Christopher Mattern

"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"

Re: $! ????

Quoted text here. Click to load it

Quoted text here. Click to load it

The code in question use's Errno.  If you looked at the code for Errno,
you would find the following:
http://search.cpan.org/~nwclark/perl-5.8.5/ext/Errno/Errno_pm.PL">http://search.cpan.org/~nwclark/perl-5.8.5/ext/Errno/Errno_pm.PL )

 Errno also makes %! magic such that each element of %! has a non-zero
value only if $! is set to that value.

Paul Lalli

Site Timeline