#!/usr/bin/perl # exchange.pl - currency exchange "module" # # Update: 990818 08:30:10, bobby@bofh.dk # # Revised: 2001-09-13, simon@newmediawhore.com # # Fixed to work with Euros, and not return Zimbabwean # Dollars for any unknown currency :) # # Overhauled 2005-01-08 muttley BEGIN { eval qq{ use Finance::Currency::Convert::XE; }; $no_exchange++ if($@); } sub exchange { my($From, $To, $Amount) = @_; return "Currency conversion not working" if $no_exchange; my $obj = new Finance::Currency::Convert::XE(); return "Currency conversion not working" unless $obj; my $val = $obj->convert( 'source' => $From, 'target' => $To, 'value' => $Amount, 'format' => 'number' ); return "Currency conversion failed - ".$obj->error unless $val; return "$Amount $From is $val $To"; } "That's all folks ;-)"; __END__ =head1 NAME exchange.pl - Exchange between currencies =head1 PREREQUISITES Finance::Currency::Convert::XE =head1 PARAMETERS exchange =head1 PUBLIC INTERFACE Exchange for|[in]to =head1 DESCRIPTION Contacts C and grabs the exchange rates; warning - the currency code is a bit cranky. =head1 AUTHORS original Bobby update muttley =cut