Finance-Currency-Convert-DnB
view release on metacpan or search on metacpan
lib/Finance/Currency/Convert/DnB.pm view on Meta::CPAN
5678910111213141516171819202122232425our
@ISA
=
qw/Exporter/
;
our
@EXPORT
=
qw/currency update_currency currencies/
;
our
$VERSION
=
'0.2'
;
our
$currency
;
use
File::Spec;
use
XML::Simple;
use
LWP::Simple;
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 )