Finance::Currency::Convert::Custom - Update for Finance::Currency::Convert with ability of own rates updating on the fly.
Finance::Currency::Convert
use Finance::Currency::Convert::Custom; use LWP::UserAgent; my @currencies = ('EUR','GBP','AUD','CAD','BRL','DKK','HKD','KRW','NOK','SEK','CHF','TWD'); my $converter = new Finance::Currency::Convert::Custom; foreach my $currency (@currencies){ #also, updateRates has same call, you should add ref to your sub as first param - others like in Finance::Currency::Convert #also, if ref to sub is not defined then own internal example is used $converter->updateRate(\&own_fetch_rate,$currency, "USD"); my $rate = $converter->convert(1, $currency, "USD"); } sub own_fetch_rate{ my ($cur_from, $cur_to) = @_; my $browser = LWP::UserAgent->new; my $response = $browser->get( "http://finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s=".$cur_from.$cur_to."=X" ); my $data = $response->content(); my @arr = split /,/,$data; return $arr[1]; }
Finance::Currency::Convert::Custom should be useful for people, who needs to have own rates or have own methods for fetching them, but who likes Finance::Currency::Convert. Its needed because of Finance::Currency::Convert strong dependency of Finance::Quote. The last module fails a lot last time.
Finance::Currency::Convert::Custom
Dmitry Nikolayev <dmitry@cpan.org>, http://makeperl.com
Thanks to Freecause, http://freecause.com for giving opportunity to make same for company and community ;)
Copyright (C) 2009 by Dmitry Nikolayev
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Finance::Currency::Convert::Custom, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Finance::Currency::Convert::Custom
CPAN shell
perl -MCPAN -e shell install Finance::Currency::Convert::Custom
For more information on module installation, please visit the detailed CPAN module installation guide.