Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: Process ID of qx

by kyle (Abbot)
on Mar 05, 2007 at 14:16 UTC ( [id://603212]=note: print w/replies, xml ) Need Help??


in reply to Re: Process ID of qx
in thread Process ID of qx

my $pid = open my $ph, "| $_[0]" or die "$!: $_[0]";

Your open is opening for write instead of read. The command's output goes to STDOUT instead of to your variable. Try this:

sub pidqx { # returns pid + the usual backtick result my ( $cmd ) = @_; my $pid = open my $ph, '-|', $cmd or die "$!: $cmd"; local $/ = undef(); my $backtick = <$ph>; close $ph; return ( $pid, $backtick ); }

Also, you don't have to wait for the command to finish because close does that for you.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://603212]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-25 06:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found