Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: qx and $!

by Bro. Doug (Monk)
on Oct 19, 2006 at 02:46 UTC ( [id://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 (Patriarch) 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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://579260]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-04-18 18:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found