ultranerds has asked for the wisdom of the Perl Monks concerning the following question:
However, when I run it - I now get:#!/usr/local/bin/perl use utf8; use Locale::Currency; use File::Basename; use Cache::FileCache; use Finance::Quote; use POSIX; print "FOO: ". get_price("CHF","EUR","50") . "\n"; sub get_price { my ($currency_from,$currency_to,$amount) = @_; my ($filename) = fileparse($0, '.pl'); my $cache = Cache::FileCache->new({ cache_root => "$ENV{HOME}/.$filename", default_expires_in => '1 day', }); my $quote = Finance::Quote->new(); my $ratio = $cache->get("$currency_from:$currency_to"); $ratio = $quote->currency($currency_from, $currency_to) unless defined $ratio; die "sorry, cannot convert from $currency_from to $currency_to\n" unless defined $ratio; $cache->set("$currency_from:$currency_to", $ratio); return $amount * $ratio }
-bash-3.2$ perl test.cgi [Sat Jan 18 13:09:21 2014] test.cgi: Illegal division by zero at /usr/ +lib/perl5/site_perl/5.8.8/Finance/Quote/IndiaMutual.pm line 27. [Sat Jan 18 13:09:21 2014] test.cgi: Compilation failed in require at +(eval 34) line 1. [Sat Jan 18 13:09:21 2014] test.cgi: BEGIN failed--compilation aborted + at (eval 34) line 1. [Sat Jan 18 13:09:21 2014] test.cgi: at test.cgi line 45
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Finance::Quote giving weird error
by ww (Archbishop) on Jan 18, 2014 at 13:07 UTC | |
by ultranerds (Hermit) on Jan 18, 2014 at 15:13 UTC | |
|
Re: Finance::Quote giving weird error
by ww (Archbishop) on Jan 18, 2014 at 12:41 UTC |