Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks & others,
I don't understand what happens in the script below. Why does the output get jumbled as soon as I remove the comment before my $processes = `ps au`? I would have expected everything inside the child process to run in order, but it looks like the part between the backticks is running asynchronically or something???
This is part of a much larger script in which I need to extract some information from 'ps au' to be used in the script.for (1..3) { my $fork_pid = fork(); if (! $fork_pid) { print "hello" . "\t"; # my $processes = `ps au`; print "world" . "\n"; exit 0; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Backticks within child process
by zentara (Cardinal) on Jul 09, 2012 at 16:56 UTC | |
|
Re: Backticks within child process
by onelesd (Pilgrim) on Jul 09, 2012 at 17:03 UTC | |
|
Re: Backticks within child process
by frozenwithjoy (Priest) on Jul 09, 2012 at 16:50 UTC | |
|
Re: Backticks within child process
by locked_user sundialsvc4 (Abbot) on Jul 09, 2012 at 17:53 UTC | |
|
Re: Backticks within child process
by Anonymous Monk on Jul 09, 2012 at 19:09 UTC | |
by dave_the_m (Monsignor) on Jul 09, 2012 at 23:58 UTC | |
|
Re: Backticks within child process
by The Code Captain (Initiate) on Jul 09, 2012 at 17:49 UTC |