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.
&convert
Codes are used to identify currencies: you may view them in the values of the %currencies hash, where keys are descriptions of the currencies.
%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.
undef
$CHAT
$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....
s
GBPUSD
The old convert routine: accesses http://finance.yahoo.com/m5?a=amount&s=start&t=to, where 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, print $DATE).
convert
http://finance.yahoo.com/m5?a=amount&s=start&t=to
start
to
amount
print $DATE
None.
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.
LWP::UserAgent: HTTP::Request; http://www.macosxhints.com/article.php?story=20050622055810252; http://www.gummy-stuff.org/Yahoo-data.htm.
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.
To install Finance::Currency::Convert::Yahoo, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Finance::Currency::Convert::Yahoo
CPAN shell
perl -MCPAN -e shell install Finance::Currency::Convert::Yahoo
For more information on module installation, please visit the detailed CPAN module installation guide.