Hello
amitsq,
I'm not at all a parallel monk and here there are, very skilled.
> my $pm= new Parallel::ForkManager(8); #didn’t matter if it’s 1 or 5 or whatever else
your original program crash here too and in the same way, but with 1 does not.
I have borrowed the below modifying it a little from example from P::FM docs and the resulting code runs with no crashes. At least something to start with:
use Parallel::ForkManager;
use LWP::Simple;
my $pm = Parallel::ForkManager->new(10);
LINKS:
for my $link ('http://us.a1.yimg.com/us.yimg.com/i/ww/m5v9.gif',
'http://hooboy.no-such-host.int/',
'http://www.yahoo.com',
'http://www.ora.com/ask_tim/graphics/asktim_header_main.gif',
'http://www.guardian.co.uk/',
'http://www.pixunlimited.co.uk/siteheaders/Guardian.gif') {
$pm->start and next LINKS;
my ($content_type, $document_length, $modified_time, $expires, $
+server) = head($link);
print "$link fetched: declared lenght $document_length, \n";
$pm->finish;
};
# output
http://hooboy.no-such-host.int/ fetched: declared lenght ,
http://us.a1.yimg.com/us.yimg.com/i/ww/m5v9.gif fetched: declared leng
+ht 5611,
http://www.guardian.co.uk/ fetched: declared lenght 628397,
http://www.ora.com/ask_tim/graphics/asktim_header_main.gif fetched: de
+clared lenght ,
http://www.pixunlimited.co.uk/siteheaders/Guardian.gif fetched: declar
+ed lenght ,
http://www.yahoo.com fetched: declared lenght 12,
L*
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.