#!/opt/gnu-irix/bin/perl
use strict;
use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
my $ua = new LWP::UserAgent;
my $url = 'http://www.usps.com/zip4/zip4_response.jsp';
my $data = [
'Selection' => '1',
'address1' => $ARGV[0],
'address2' => '',
'city' => '',
'state' => '',
'zipcode' => $ARGV[1],
'Submit' => ''
];
$ua = new LWP::UserAgent;
my $resp = $ua->request(POST $url, $data);
if ($resp->is_success())
{
print $resp->content();
}
else
{
print "OOPS\n", $resp->as_string();
}
####
address.pl '1713 62nd Avenue' '20785'
####
OOPS
HTTP/1.1 500 (Internal Server Error) Server Error
Connection: close
Date: Fri, 16 Aug 2002 15:20:52 GMT
Server: Netscape-Enterprise/6.0
Content-Length: 305
Content-Type: text/html
Client-Date: Fri, 16 Aug 2002 15:20:45 GMT
Client-Peer: 56.0.78.66:80
Title: Server Error
Server Error
Server Error
This server has encountered an internal error which prevents it from fulfilling your request. The most likely
cause is a misconfiguration. Please ask the administrator
to look for messages in the server's error log.