#! perl -slw use strict; use LWP::Simple; use threads stack_size => 4096; use threads::shared; use Thread::Queue; our $THREADS //= 500; my %log :shared; my $Q = new Thread::Queue; my @threads = map async( sub { while( my $url = $Q->dequeue() ) { my @info = head 'http://' . $url; lock %log; $log{ $url } = join $;, map{ local $^W; $_ // '*n/a*' } @info; } } ), 1 .. $THREADS; while( <> ) { chomp; sleep 1 if $Q->pending > $THREADS; $Q->enqueue( $_ ); } $Q->enqueue( (undef) x $THREADS ); $_->join for @threads; my( $url, $status ); print "$url : $status" while ( $url, $status ) = each %log; __END__ c:\test>t-head-urls -THREADS=100 urls.list.small www.t-mobile.com : text/html; charset=utf-8?109511?873075813?*n/a*?Microsoft-IIS/7.0 www.avocent.com : text/html; charset=UTF-8?114030?*n/a*?*n/a*?Microsoft-IIS/7.0 www.fsw.com : text/html?9926?1306121940?*n/a*?Apache/2.2.21 (Unix) mod_ssl/2.2.21 OpenSSL/0.9.7a mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 mod_fcgid/2.3.5 Resin/3.1.10 Sun-ONE-ASP/4.0.3 www.voodoopc.com : text/html?6021?*n/a*?1328712575?Apache www.creative.com : text/html; Charset=iso-8859-1?42330?*n/a*?1328705318?Microsoft-IIS/6.0 www.belkin.com : www.argus-systems.com : text/html?8111?1320697393?*n/a*?Apache/2.2.6 (Unix) mod_python/3.3.1 Python/2.5.1 mod_ssl/2.2.6 OpenSSL/0.9.8g www.iss.net : text/html; charset=UTF-8?*n/a*?*n/a*?*n/a*?Apache www.Joyent.COM : text/html; charset=UTF-8?*n/a*?*n/a*?*n/a*?Apache ...