Courtesy of Randal L. Schwartz, in http://www.sysadmin.org, July 2003
Hit the US Time website via the daytime protocol
#!/usr/bin/perl
use strict;
use IO::Socket::INET qw(CRLF);
my $client = IO::Socket::INET->new('time.gov:daytime')
or die "new: $@";
{
local $/;
$_ = <$client>;
}
if (defined $_)
{
print
"response from ",
$client->peerhost,
" port ",
$client->peerport,
" was:\n$_";
}
Grabbing the entire html dump of its webpage
#!/usr/bin/perl
use strict;
use IO::Socket::INET qw(CRLF);
my $client = IO::Socket::INET->new('time.gov:http')
or die "new: $@";
print $client "GET / HTTP/1.0", CRLF, CRLF;
print while <$client>;
Same thing, but a simpler method
#!/usr/bin/perl
use strict;
use LWP::Simple;
getprint("http://www.time.gov");
--
MattWalsh - 06 Aug 2003