Dear monks, once again I humbly seek your wisdom,
I'm using Parallel::Forkmanager to download a list of urls, then I have other functions which process them. I would like when I download by: $url_list{$pagename} = get($url_list{$pagename}) to keep that value for $pagename, but it seems that the value instantiated within the ForkManager loop is not carried outside the loop.
I cannot simply call some sub from inside the loop and process them on the fly since I need to download all the urls before I begin processing, and I dont want to write to a file since that takes too long. This demonstrates the problem:
use Parallel::ForkManager; @values = (0, 0); my $pm=new Parallel::ForkManager(2); foreach $value (@values) { $pm->start and next; print"$value"; $value = 1; print"$value"; $pm->finish; }; $pm->wait_all_children; foreach $value (@values) { print"$value"; };
It prints:
010100
when I want: 010111.
If any learned monk could help I would be most grateful,
cheers,
Ntav
Thats your answer to everything Homer: "lets go and live under the sea". Well it won't work this time!
Marge

In reply to Parallel::ForkManager vs global variables by Ntav

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.