#!/usr/bin/perl -Tw
use strict;
use CGI qw(:standard);
print header;
if (param('foo')) {
print "you sent ", param('foo');
}
else {
print start_html,start_form,textfield('foo'),
submit,end_form,end_html,
;
}
####
use strict;
use LWP;
use HTTP::Request::Common;
my $url = 'http://localhost/cgi-bin/simple.cgi';
my $ua = LWP::UserAgent->new;
my $request = POST($url, Content => [foo=>'hello world']);
my $response = $ua->request($request);
print $response->content, "\n";
####
use strict;
use IO::Socket qw(:DEFAULT :crlf);
$/ = CRLF . CRLF;
my $sock = IO::Socket::INET->new(
Proto => 'tcp',
PeerAddr => 'localhost',
PeerPort => 'http(80)',
);
print $sock "GET /cgi-bin/simple.cgi?foo=hello%20world",$/;
my $header = <$sock>;
print $header;
my $data;
print $data while read($sock,$data,1024) > 0;