On Mon, May 15, 2006 at 04:46:07PM -0400, Tom Allison wrote: > I've got a *bunch* of code that I've been rewriting recently and ran > into a rather weird problem. > > it won't fork. > > If I write the following: > > foreach my $file ( @$files ) { > my $pid = fork(); > print "$pid --> $file\n"; > [....] > } > > I will get an output of: > 0 --> file_one > 3242 --> file_one > 0--> file_two > > but no 3243-->file_two.
You don't say anything about what you are trying to do, but when I run code such as: $ perl -le 'for (1 .. 2) { my $p = fork; print "[$_][$p]" }' I see the output just as I expected: [1][0] [2][0] [2][29760] [1][29759] [2][0] [2][29761] How many files do you have? And you do realise that this is going to grow exponentially, don't you? I'd be surprised if this is actually what you want. Perhaps you only want the parent to actually fork? Have you read perlipc? -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>