Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: qx and $!

by Bro. Doug (Monk)
on Oct 19, 2006 at 02:46 UTC ( #579260=note: print w/replies, xml ) Need Help??


in reply to qx and $!

On a Mac, it prints nothing.

However, if you change this to:
perl -e 'print qx(date);'
... you'll get the date printed on the command line.

qx executes the system's date command and returns it as a quoted string. $! refers to the last error thrown by a statement that isn't in an eval block.

Why it's a 'Bad file descriptor' or 'Illegal seek' is interesting. I don't know. I suspect, however, that this is what you really wanted to know when you posed this question. (?)

At any rate... I'd like to know. I'll test it tomorrow on a Linux system, since my Mac doesn't seem to freak out on an unset $!.
Bro. Doug :wq

Replies are listed 'Best First'.
Re^2: qx and $!
by ikegami (Pope) on Oct 29, 2006 at 20:02 UTC
    Some operations set $! to 0 on success (but don't count on it!). "Bad file descriptor" is error 0 on some systems.
    $! = 0; print("$!\n"); # Bad file descriptor, or Illegal seek, or ...
The Update (Late)
by Bro. Doug (Monk) on Oct 29, 2006 at 15:21 UTC
    Fellow monks,

    I promised this update about a week ago or more, but forgot. For this failure, I deeply apologize.

    However, I did the testing I promised.

    The findings are rather interesting. On a Linux system, $! only returns a 'Bad File Descriptor' message when called immediately after qx(). I tried calling $! empty, and it returned nothing.

    Perhaps someone knows how the $! is tied to the handle used to return info from qx() ?

    Peace be you, monks.
    Bro. Doug :wq

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://579260]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (7)
As of 2018-07-17 14:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (368 votes). Check out past polls.

    Notices?