- SEE ALSO
Finance::Currency::Convert::Yahoo - convert currencies using Yahoo
use Finance::Currency::Convert::Yahoo; $Finance::Currency::Convert::Yahoo::CHAT = 1; $_ = Finance::Currency::Convert::Yahoo::convert(1,'USD','GBP'); print defined($_)? "Is $_\n" : "Error."; exit; # See the currencies in a dirty way: use Finance::Currency::Convert::Yahoo; use Data::Dumper; warn %Finance::Currency::Convert::Yahoo::currencies; exit;
Using Finance.Yahoo.com, converts a sum between two currencies.
Call the module's
&convert routine, supplying three arguments: the amount to convert, and the currencies to convert from and to.
Codes are used to identify currencies: you may view them in the values of the
%currencies hash, where keys are descriptions of the currencies.
In the event that attempts to convert fail, you will recieve
undef in response, with errors going to STDERR, and notes displayed if the modules global
$CHAT is defined.
$value = &convert( $amount_to_convert, $from, $to);
Requires the sum to convert, and two symbols to represent the source and target currencies.
In more detail, access http://finance.yahoo.com/d/quotes.csv?s=GBPEUR=X&f=l1, where the value of
s (in the example,
GBPUSD) is the value of the source and target currencies, and the rest is stuff I've not looked into....
convert routine: accesses
start is the currency being converted,
to is the target currency, and
amount is the amount being converted. The latter is a number; the former two codes defined in our
%currencies hash. (For the date this was last checked,
Please see the enclosed file CHANGES.
If this doesn't work, Yahoo have probably changed their URI or HTML format. Let me know and I'll fix the code. Or by all means send a patch. Please don't just post a bad review on CPAN, I don't get CC'd them.
Lee Goddard, lgoddard -at- cpan -dot- org.
Copyright (C) Lee Goddard, 2001, 2005, ff. - All Rights Reserved.
This library is free software and may be used only under the same terms as Perl itself.