use LWP::Simple;
use Parallel::ForkManager;
@links=(
["http://prdownloads.sourceforge.net/sweethome3d/SweetHome3D-2.1-windows.exe","SweetHome3D-2.1-windows.exe"],
["http://prdownloads.sourceforge.net/sweethome3d/SweetHome3D-2.1-macosx.dmg","SweetHome3D-2.1-macosx.dmg"],
["http://prdownloads.sourceforge.net/sweethome3d/SweetHome3DViewer-2.1.zip","SweetHome3DViewer-2.1.zip"],
);
# Max 30 processes for parallel download
my $pm = new Parallel::ForkManager(30);
foreach my $linkarray (@links) {
my $pid = $pm->start and next; # do the fork
my ($link,$fn) = @$linkarray;
warn "Cannot get $fn from $link"
if getstore($link,$fn) != RC_OK;
print "$pid = $link is done ";
$pm->finish; # do the exit in the child process
}
$pm->wait_all_children;
after this execution i am going pid is zero
0 = http://prdownloads.sourceforge.net/sweethome3d/SweetHome3DViewer-2.1.zip is done 0 = http://prdownloads.sourceforge.net/sweethome3d/SweetHome3D-2.1-macosx.dmg is done 0 = http://prdownloads.sourceforge.net/sweethome3d/SweetHome3D-2.1-windows.exe is done
But now I really thinking whether its really doing the fork. Why I am getting all times 0 as pid in Parallel::ForkManager?
EDIT 2
i have 2 changes
my $pid = $pm->start ; # do the fork
and $$
for process id
21892 = http://prdownloads.sourceforge.net/sweethome3d/SweetHome3D-2.1-windows.exe is done 21893 = http://prdownloads.sourceforge.net/sweethome3d/SweetHome3D-2.1-windows.exe is done 21892 = http://prdownloads.sourceforge.net/sweethome3d/SweetHome3D-2.1-macosx.dmg is done 23120 = http://prdownloads.sourceforge.net/sweethome3d/SweetHome3D-2.1-macosx.dmg is done 21892 = http://prdownloads.sourceforge.net/sweethome3d/SweetHome3DViewer-2.1.zip is done 23146 = http://prdownloads.sourceforge.net/sweethome3d/SweetHome3DViewer-2.1.zip is done
But now I am getting 2 twice. Why I am getting this?