use strict; use warnings; use LWP::UserAgent; my $output_file = "output.txt"; my %html; # Localtime printouts check only # how long it takes to download the html, # not do the printing print scalar localtime , "\n"; while () { $html{$_} = get_html($_); } print scalar localtime , "\n"; #output: #Thu Mar 3 13:10:59 2005 #Thu Mar 3 13:11:16 2005 # ~ 17 seconds #print out the html as a sanity check. open F, "> output.txt" or die "couldn't open output file"; foreach (keys %html) { print F "$_:\n" . $html{$_}; } close F; sub get_html { my $url = shift; my $ua = LWP::UserAgent->new; $ua->agent('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)'); $ua->timeout(30); my $request = HTTP::Request->new('GET', "$url"); my $www = $ua->request($request); my $html; unless ( $www->is_success ) { # Attempt to get html failed. die "Failed to get html for $url" } else { # html retrieved ok. $html = $www->content; } return $html; } __DATA__ http://www.google.com http://www.yahoo.com http://www.amazon.com http://www.ebay.com http://www.perlmonks.com http://news.yahoo.com http://news.google.com http://www.msn.com http://www.slashdot.org http://www.indymedia.org