#! perl -slw use strict; use threads; use threads::shared;; use LWP::Simple; use constant MAX_THREADS => 3; chomp( my @urls = ); my %store :shared; my $threads :shared; for my $page ( @urls ) { async { $store{ $page } = get( 'http://' . $page ) or die "Failed to get $page"; print "Loaded $page"; } and $threads++; if( $threads > MAX_THREADS ) { if( my @joinable = threads->list(threads::joinable) ) { $_->join for @joinable; $threads -= @joinable; } else { sleep 1; } } } $_->join for threads->list; printf "Press enter to see the data gathered"; ; print "*** $_ ***\n$store{ $_ }\n\n" for keys %store; __END__ www.yahoo.com www.microsoft.com www.bbc.co.uk www.ibm.com www.google.com www.bt.co.uk