#!/usr/bin/perl -w # getservertype3.pl - a threaded version use strict; use IO::Socket; use Thread; my @hosts = qw( www.ssc.com www.linuxjournal.com www.perl.com www.perl.org www.nytimes.com www.onsight.com www.avue.com ); sub doit { my $server = shift; print "processing $_...\n"; my $sock = new IO::Socket::INET( PeerAddr => $server, PeerPort => 80, Proto => 'tcp'); $sock or die "no socket for $_: $!"; print $sock "GET / HTTP/1.0\n\n"; while (<$sock>) { if (/^Server:\s*(.*)/) { print " $server: $1\n"; last; } } } for (@hosts) { my $t = new Thread \&doit, $_; }