Perlbeginner1 has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use WWW::Mechanize::Firefox; use strict; use warnings; #use Parallel::ForkManager; #my $fork = Parallel::ForkManager->new(25); #sites my @urls = qw(http://www.google.com http://www.yahoo.com http://www.cn +n.com http://www.bing.com http://www.nbcnews.com/... and thosusand others more ); #temp base dir my $temp = '/home/myspace/cgi-bin/'; for my $each (@urls){ #$fork->start and next; my $mech = WWW::Mechanize::Firefox->new(launch => 'firefox',create + => 1,); $each =~ /www\.(\w+)\.com/; my $name = $1; print "creating $name.png\n"; $mech->get($each); my $png = $mech->content_as_png(undef, undef, {width => 240,height + => 240}); my $dir_name = "$temp/$name".".png"; open my $file, ">", "$dir_name" or die "couldnt create $temp/$1.pn +g"; binmode $file; print {$file} $png; close $file; sleep 5; # sleep some to give it a little time to make sure things + compleated..... you'll need this more using fork #$fork->finish; } print "Well All done!\n"; #$fork->wait_all_children;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Parallel::ForkManager - machine way tooo slow - need a quad-core machine
by flexvault (Monsignor) on Oct 26, 2012 at 14:14 UTC | |
|
Re: Parallel::ForkManager - machine way tooo slow - need a quad-core machine
by zentara (Cardinal) on Oct 26, 2012 at 15:01 UTC | |
|
Re: Parallel::ForkManager - machine way tooo slow - need a quad-core machine
by Old_Gray_Bear (Bishop) on Oct 26, 2012 at 16:36 UTC | |
by Perlbeginner1 (Scribe) on Oct 27, 2012 at 07:27 UTC | |
|
Re: Parallel::ForkManager - machine way tooo slow - need a quad-core machine
by Anonymous Monk on Oct 26, 2012 at 17:38 UTC |