-->
#!/usr/bin/perl
use warnings;
use strict;
use IO::Socket;
my $remote_host = '192.168.1.107';
my $URI = '/index.html';
my $remote_port = 80;
my @response;
my $date_last_modified = 'unknown';
my $socket = IO::Socket::INET->new
( PeerAddr => $remote_host,
PeerPort => $remote_port,
Proto => 'tcp',
Timeout => '10',
Type => SOCK_STREAM,
) or die "Connecting to $remote_host:$remote_port:$@";
print $socket "HEAD $URI HTTP/1.0\n\n";
@response = <$socket>;
foreach (@response){
$date_last_modified =$1 if (/^Last-modified: (.+?)\n/i);
}
print "Last modification date: $date_last_modified\n";
close ($socket);
exit;

发表评论