| Finance-Currency-Convert-Yahoo documentation | view source | Contained in the Finance-Currency-Convert-Yahoo distribution. |
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....
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).
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.
| Finance-Currency-Convert-Yahoo documentation | view source | Contained in the Finance-Currency-Convert-Yahoo distribution. |