NAME

Data::MoneyCurrency - Get information for different currencies

VERSION

version 0.30

SYNOPSIS

use Data::MoneyCurrency qw(get_currency get_currencies_for_country);

my $currency = get_currency(currency => 'usd');
# $currency = {
#     alternate_symbols    => ['US$'],
#     decimal_mark         => '.',
#     disambiguate_symbol  => 'US$',
#     html_entity          => '$',
#     iso_code             => 'USD',
#     iso_numeric          => '840',
#     name                 => 'United States Dollar',
#     priority             => 1,
#     smallest_denomination => 1,
#     subunit              => 'Cent',
#     subunit_to_unit      => 100,
#     symbol               => '$',
#     symbol_first         => 1,
#     thousands_separator  => ',',
# }

my $currency = get_currency(country => 'fr');
# $currency contains the hash for EUR

my $currencies = get_currencies_for_country('cu');
# $currencies = ['cuc', 'cup']

DESCRIPTION

Data::MoneyCurrency provides currency data lookup by ISO 4217 currency code or ISO 3166-1 alpha-2 country code. It covers all ISO 4217 currencies plus select non-ISO currencies (e.g. BTC) and 250+ countries and territories.

The currency data is sourced from the Ruby Money library but is maintained independently. The relevant data files are already included in this distribution, so there is no dependency on Ruby.

EXPORT

Nothing is exported by default. The following functions are available for export:

use Data::MoneyCurrency qw(get_currency get_currencies_for_country);

SUBROUTINES/METHODS

get_currency

my $currency = get_currency(currency => 'USD');
my $currency = get_currency(country  => 'fr');

Takes a hash of arguments with exactly one key — either currency (an ISO 4217 currency code such as usd) or country (an ISO 3166-1 alpha-2 country code such as fr). Input is case-insensitive.

Returns a hashref containing currency information, or undef if the currency or country is not recognised. The returned hash contains the following keys:

iso_code — ISO 4217 currency code (e.g. USD)
iso_numeric — ISO 4217 numeric code (e.g. 840)
name — full currency name (e.g. United States Dollar)
symbol — currency symbol (e.g. $)
alternate_symbols — arrayref of alternate symbols (e.g. ['US$'])
disambiguate_symbol — symbol used when disambiguation is needed
html_entity — HTML entity for the symbol
subunit — name of the fractional unit (e.g. Cent)
subunit_to_unit — number of subunits per unit (e.g. 100)
symbol_first1 if the symbol precedes the amount, 0 otherwise
decimal_mark — character used as the decimal separator
thousands_separator — character used as the thousands separator
smallest_denomination — smallest amount of cash in circulation (in subunits)
priority — relative priority for display ordering

Croaks if called with no arguments, with both currency and country, or with unrecognised keys.

When using country for a country that has multiple currencies (e.g. Cuba), the function croaks. Use "get_currencies_for_country" to retrieve the full list first.

get_currencies_for_country

my $currencies = get_currencies_for_country('cu');
# $currencies = ['cuc', 'cup']

my $currencies = get_currencies_for_country('fr');
# $currencies = ['eur']

Takes a single argument — an ISO 3166-1 alpha-2 country code (case-insensitive) — and returns an arrayref of lowercase currency code strings. Returns undef if the country is not recognised.

Croaks if called with no arguments or more than one argument.

SEE ALSO

BUGS

Please report any bugs or feature requests through the web interface at https://github.com/OpenCageData/perl5-Data-MoneyCurrency.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Data::MoneyCurrency

You can also look for information at:

ACKNOWLEDGEMENTS

Original version by David D Lowe (FLIMM)

AUTHOR

edf <cpan@opencagedata.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by OpenCage GmbH.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.