#!/usr/bin/perl use strict; # https://www.perlmonks.org/?node_id=11154241 use warnings; use Forking::Amazing; use Time::HiRes qw( time ); use LWP::UserAgent; my $ua = LWP::UserAgent->new; my %answers; Forking::Amazing::run 23, # maxforks, less than two dozen sub # runs in child { my $starttime = time; my ($url) = @_; print "child debug starting $url\n"; $ua->agent($url); my $req = HTTP::Request->new(GET => $url); my $res = $ua->request($req); my $status = $res->status_line($req); my $data = $res->content; print "child debug ending $url\n"; return { len => length $data, status => $status, status => $status, took => sprintf "%.3f seconds", time - $starttime }; }, sub # runs in parent with results from child { my ($url, $hashref) = @_; # url child, hashref from child $answers{$url} = $hashref; }, map 'https://' . tr/\n//dr, ; # list of URLs to process use Data::Dump 'dd'; dd \%answers; __DATA__ gap.com amazon.com ebay.com wunderground.com imdb.com google.com nosuchurl.com underarmour.com disney.com espn.com