Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get currency by country?

Tags:

currency

perl

How would you guys figure out currency only having country code? Ideally in Perl but I think any other language solution would be easy enough to port.

Thanks

like image 507
tkane Avatar asked Dec 13 '25 14:12

tkane


1 Answers

It looks like Locale::Object::Currency from CPAN contains what you need. It doesn't seem to have been updated since 2007, though.

#!/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.
like image 135
Sdaz MacSkibbons Avatar answered Dec 16 '25 02:12

Sdaz MacSkibbons



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!