Finance-Currency-Convert-DnB

 view release on metacpan or  search on metacpan

lib/Finance/Currency/Convert/DnB.pm  view on Meta::CPAN

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
our @ISA = qw/Exporter/;
our @EXPORT = qw/currency update_currency currencies/;
our $VERSION = '0.2';
 
our $currency;
use Slurp;
 
sub update_currency {
    my $filename = File::Spec->tmpdir() . "/currency_list_" . ((defined $>) ? $> : "") . ".xml";
    #only download XML twice a day
    if (!-e $filename || time()-43200 < -M $filename || $_[0]) {
        is_success ($_=getstore('http://www.dnbnor.no/portalfront/datafiles/miscellaneous/csv/kursliste_ws.xml', $filename))
            or die 'Failed to get list of currencies; http error code: ' . $_;
 
    }
 
    my $content = slurp $filename;
    $currency = XMLin($content, KeyAttr => ["kode"]);



( run in 0.442 second using v1.01-cache-2.11-cpan-87723dcf8b7 )