in reply to How to get child pid from backtics

note: this pid is actually the pid of the subshell. (updated)

$pid = open( my $proc, "-|", "ls -l" ); print "pid $pid\n"; my @lines = <$proc>; print @lines;

Replies are listed 'Best First'.
Re^2: How to get child pid from backtics
by Anonymous Monk on Dec 09, 2004 at 15:19 UTC
    No, it's not the pid of the subshell, because there isn't a subshell. Perl only calls a subshell if the command to call contains characters that are special to the shell (except whitespace) - otherwise Perl will split given string on whitespace, and execute the command (with any arguments) directly. In this case, perl will do an execv of ls, passing it -l as its sole argument.

    Had you written:

    $pid = open(my $proc, "-","ls -l>/tmp/foo");
    then $pid would contain the pid of a shell.