#!/usr/bin/perl # Set up test variables $upsAction = "3"; $upsProduct = "GNDRES"; $OriginPostalCode = "91706"; $DestPostalCode = "12345"; $DestCountry = "US"; $PackageWeight = "1"; $Value="20"; $function = "GET"; $workFile = "/using/services/rave/qcostcgi.cgi"; $versionInfo = "HTTP/1.0\n\n"; $workString = "?accept_UPS_license_agreement=yes"; $workString .= "&10_action=$upsAction"; $workString .= "&13_product=$upsProduct"; $workString .= "&15_origPostal=$OriginPostalCode"; $workString .= "&19_destPostal=$DestPostalCode"; $workString .= "&22_destCountry=$DestCountry"; $workString .= "&23_weight=$PackageWeight"; $workString .= "&24_value=$Value"; $request = "$function $workFile$workString $versionInfo"; use IO::Socket; $socket = IO::Socket::INET->new(PeerAddr => "www.ups.com", PeerPort => 80, Proto => "tcp", Type => SOCK_STREAM) or die "Couldn't connect to www.ups.com: $@\n"; print $socket "$request"; $i = 0; while (<$socket>) { $array[$i] = $_; $i++ } close($socket); print STDOUT "Content-type: text/html\n\n"; # $array[6] contains the information needed # (all others are header info) $answer = $array[6]; chop $answer; # remove newline chop $answer; # remove trailing % @ups = split(/\%/, $answer); # print out entire reply from UPS print STDOUT "$answer
\n"; # print out UPS header info print STDOUT "Header: $ups[0]
\n"; # print out UPS shipping charge print STDOUT "UPS charge: $ups[10]
\n"; exit;