Search notes:

Perl module IO::Socket

The following simple script does a very basic HTTP request. It takes two arguments: the host and the path:
#!/usr/bin/perl
use warnings;
use strict;

use IO::Socket;

my $host = shift or die; 
my $path = shift or die;

my $socket = IO::Socket::INET->new(
  PeerAddr    => $host,
  PeerPort    =>  80,
  Proto       => 'tcp',
  Timeout     =>  1
)
or die "Could not connect";

print $socket "GET $path HTTP/1.0\x0d\x0a";
print $socket "Host: $host\x0d\x0a";
print $socket "\x0d\x0a";

while (my $line = <$socket>) {
  print $line;
}
Github repository PerlModules, path: /IO/Socket/script.pl

See also

echo server and client with Perl module IO::Socket
Perl modules

Index