There's more than one way to do things | |
PerlMonks |
Re^2: Please Explain the Parallel::ForkManager Idiom my $pid = $pm->start and next;by Jim (Curate) |
on Feb 04, 2014 at 16:56 UTC ( [id://1073442]=note: print w/replies, xml ) | Need Help?? |
Gosh, I remember reading bart's excellent tutorial Mr. Peabody Explains fork() years ago when fork() was relatively new to Perl on Windows. Obviously, I wasn't able to wrap my head around it then, and I continue to struggle with it today. But I'm more determined now than I was then to understand how it works. At least one light bulb has gone on above my head after reading this and seeing its accompanying graphic in blue and green text:
The important difference here is the explanation that "the code is executed instruction-by-instruction until the fork() is reached." This is the first time I've seen it plainly stated that fork() alters the ordinary sequential execution of statements in a Perl program. This helps me begin to understand what's going on in the mystifying example program I'm studying. I likened fork() in Perl to job control in the Unix shell, but I'm now realizing they're not the same thing at all. A shell loop that launches commands in the background with & is not the same as a fork() in Perl. Jim
In Section
Seekers of Perl Wisdom
|
|