#!/usr/bin/perl use warnings; use strict; use Benchmark; my $t0 = Benchmark->new; use Parallel::ForkManager; my @links=("ALPHA","Numeric"); # Max 30 processes for parallel download my $pm = Parallel::ForkManager->new(2); sub alpha { foreach my $i (900 .. 1900) { print 'A',"\t"; } } sub numeric { foreach my $j (1 .. 1000) { print $j,"\t"; } } LINKS: foreach my $linkarray (@links) { $pm->start and next LINKS; # do the fork if ($linkarray eq "ALPHA") { alpha(); } if ($linkarray eq "Numeric") { numeric(); } $pm->finish; # do the exit in the child process } $pm->wait_all_children; my $t1 = Benchmark->new; my $td = timediff($t1, $t0); print "the code took:",timestr($td),"\n";