How to get currency by country?

How do you guys determine the currency with just the country code? Ideally in Perl, but I think any other language solution would be easy enough to port.

thank

+3
source share
2 answers

Looks like Locale :: Object :: Currency from CPAN contains what you need. However, it does not appear to have been updated since 2007.

#!/usr/bin/perl

use Locale::Object::Currency;
use Data::Dumper;
use strict;
use warnings;

my $bucks = Locale::Object::Currency->new( country_code => 'us' );
print Dumper( $bucks->symbol, $bucks->code, $bucks->name );  # etc..

#print Dumper $bucks;  # don't do this in production; use the method interface;
                       # but it does appear to have the info you need.
+2
source

You can try to find a web service that does this for you. For example, webservicex.net provides the GetCurrencyByCountry operation .

Another approach is to save the country / currency mappings somewhere in the file, and then load them into a map in your program.

-1

All Articles