I'm trying to work out why my currency converter decided its gonna stop working. To test, I've made a copy of the function into just a simple test.cgi script:
#!/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 }
However, when I run it - I now get:
-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


I'm at a bit of a loss as to whats going on - as it was working fine before :/

TIA

Andy

In reply to Finance::Quote giving weird error by ultranerds

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.