in reply to Process ID of qx
use POSIX ":sys_wait_h"; # e.g.: my ($pid, $listing) = pidqx( "ls" ); sub pidqx { # returns pid + the usual backtick result my $pid = open my $ph, "$_[0] |" or die "$!: $_[0]"; local $/ = undef(); my $backtick = <$ph>; close $ph; waitpid $pid, 0; return ( $pid, $backtick ); }
-M
Free your mind
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Process ID of qx
by kyle (Abbot) on Mar 05, 2007 at 14:16 UTC |