use strict; use warnings; use 5.010; use IO::Socket qw{ :DEFAULT :crlf }; my $host = 'localhost'; my $path = '/cgi-bin/second.pl'; my $port = 80; =pod my $CONN = IO::Socket::INET->new("$host:$port") or die "Couldn't connect: $!"; =cut my $CONN = IO::Socket::INET->new( Peerhost => $host, Peerport => 'http(80)', ) or die "Couldn't connect: $!"; my $req = "GET $path HTTP/1.0 $CRLF$CRLF"; $CONN->syswrite($req); $/ = CRLF . CRLF; #To read whole header as one 'line' binmode $CONN; #turn off \n conversion for getline() below my $header = $CONN->getline; $header =~ s/$CRLF/\n/g; say $header; $CONN->close;