#!/usr/bin/perl -w use strict; use LWP::Simple; use CGI qw/:standard/; # Created by Nathan Anderson (www.cybernexus.wox.org) Version 1.0.2 # This is an attempt to retrieve an exchange rate in order to convert it to # use US based credit card processing with Australian dollars # It has 2 main modes: Interactive and Silent # Silent is useful for ssi style variables passed to a 3rd party eg, paypal cart # Interactive is useful if you want to manually enter a number to check the price. # Without a "convert=" variable specified Silent will output the exchange rate # with a "convert=" variable it will output the exact amount rounded to 2 places. # examples: to get exchange rate "getrate.pl?silent=y" # to convert $5 AU to USD "getrate.pl?silent=y&convert=5" # to show current rate and ask for a figure to convert "getrate.pl" # to show current rate and convert $5 "getrate.pl?convert=5" my $temp = get 'http://finance.yahoo.com.au/d/quotes.csv?f=sl1t1c1ghpvo&s=USDAUD=X'; my @usdaud=split(/,/,$temp); my $convert=param('convert'); my $silent=param('silent'); if (!$silent) { print header; print start_html('Currency Rate'); print '$1 US Buys $' . $usdaud[1] . 'AU ('; printf("%.2f", $usdaud[1]); print ')'; $usdaud[2] =~ tr/\"/ /; print "
"; print '$1 AU Buys $' . (1 / $usdaud[1]) . 'US ('; printf("%.2f", 1 / $usdaud[1]); print ')'; if ($convert) { print "
A purchase of $convert AU would need to be billed at \$" . ($convert / $usdaud[1]) . 'US'; } else { print "
"; } print '
'; print "