#!/usr/bin/perl use IO::Socket; my $url = shift @ARGV or die "Pass a URL as a command-line argument."; $url =~ m{^(?:http://)?([^/:]+)(?::(\d+))?(/[^#]*)?(#.*)?$} or die "Invalid URL $url"; my ($host, $port, $path) = ($1, $2, $3); $port = "80" unless $port; $path = "/" unless $path; my $other_headers = join "", map {$_."\n"} @ARGV; my $request = < $host, PeerPort => $port, Proto => "tcp" ) or die "Error opening socket: $!"; print $sock $request; local $/ = undef; my $response = <$sock>; print $response;