Do you have a question? Post it now! No Registration Necessary. Now with pictures!
October 8, 2004, 7:19 pm
rate this thread
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".
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: $! ????
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
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 $!.
"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
Re: $! ????
The code in question use's Errno. If you looked at the code for Errno,
you would find the following:
Errno also makes %! magic such that each element of %! has a non-zero
value only if $! is set to that value.
- » Getting all directories/files from current directory and using -d flag for the directories
- — Previous thread in » PERL Discussions