> >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. > >Repeated print statements later on in the job continue to indicate that >this is not forking correctly. >
Try this: use strict; my @files = qw/aa bb cc/; foreach my $file ( @files ) { my $pid = fork(); print "$pid --> $file\n"; exit 0 unless $pid; } and print the result: 0 --> aa 2391 --> aa 0 --> bb 2392 --> bb 0 --> cc 2393 --> cc It works fine to me.Don't forget to get the childs exit if they are not needed. -- Jeff Pang NetEase AntiSpam Team http://corp.netease.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>