On Tue, May 11, 2010 at 1:23 AM, C.DeRykus <dery...@gmail.com> wrote:

> 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/
>


No  IPC::Shareable. But I can go in for Win32::MMF::Shareable.
However I went in for threads::shared which is working great so far.

You know this threads `thing` is great. So much work can be done within
short time.

------- CODE ------
use strict;
use warnings;
use threads;
use threads::shared;
use File::Basename;
use WWW::Mechanize;
use Parallel::ForkManager;

my ( %hash, @missing ) :shared;

#      ---BLAH BLAH ~ CODE HERE----

    if ( $response->is_success ) {
        my $ref = []; share( $ref );    # THIS IS SO COOL! LOL
        push @{$ref}, ( $INFO, $url );
        $hash{$base} = $ref;                     # $hash{$base} = [] ~ ERROR.
Only scalar references?
     } else {

------- END -------

That it. No questions for now.

Reply via email to