On May 10, 7:07 am, raphael.j...@gmail.com ("raphael()") wrote: > Hello, > > ---------- CODE ---------- > > #!/usr/bin/env perl > > use strict; > use warnings; > use Parallel::ForkManager; > > # Parallel::ForkManager > my $pfm = Parallel::ForkManager->new(5); > > my %hash; > for my $num ( qw/ 1 2 3 4 5 1 / ) { > $pfm->start and next; > $hash{$num}++; > $pfm->finish;} > > $pfm->wait_all_children; > > # doesn't print because %hash is undef > print "$_ => $hash{$_}\n" for sort keys %hash; > > print "hash is undef\n" unless %hash; > > ----------- END ----------- > > I want to do work on all elements of an array simultaneously. > I tried Parallel::ForkManager. It works well when you don't need to update > global value like downloading > multiple files at the same time. I want something like above that forks > while updating global values. > Are threads/fork what I am looking for? > > Any help would be *appreciated.*
If your host supports Sys V IPC, one possible solution: IPC::Shareable -- Charles DeRykus -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/