use strict; use IO::Socket; my $yahoo = IO::Socket::INET->new(Proto => "tcp", PeerPort => 80, PeerAddr => "www.yahoo.com", Timeout => 2000) || die "failed to connect\n"; my $req = "GET / HTTP/1.1\r\nHost: www.yahoo.com\r\n\r\n"; print $yahoo $req; my $count = 0; while (<$yahoo>) { print "packet count = ", ++ $count, ", and first 20 chars of the packet = ", substr($_, 0, 20), "\n"; }