Locale::Currency - ISO three letter codes for currency identification |
Locale::Currency - ISO three letter codes for currency identification (ISO 4217)
use Locale::Currency;
$curr = code2currency('usd'); # $curr gets 'US Dollar' $code = currency2code('Euro'); # $code gets 'eur'
@codes = all_currency_codes(); @names = all_currency_names();
The Locale::Currency
module provides access to the ISO three-letter
codes for identifying currencies and funds, as defined in ISO 4217.
You can either access the codes via the conversion routines
(described below),
or with the two functions which return lists of all currency codes or
all currency names.
There are two special codes defined by the standard which aren't understood by this module:
There are two conversion routines: code2currency()
and currency2code()
.
code2currency()
undef
will be returned.
$curr = code2currency($code);
currency2code()
undef
will be returned.
$code = currency2code('French Franc');
The case of the currency name is not important. See the section KNOWN BUGS AND LIMITATIONS below.
There are two function which can be used to obtain a list of all currency codes, or all currency names:
all_currency_codes()
all_currency_names()
The following example illustrates use of the code2currency()
function.
The user is prompted for a currency code, and then told the corresponding
currency name:
$| = 1; # turn off buffering
print "Enter currency code: "; chop($code = <STDIN>); $curr = code2currency($code); if (defined $curr) { print "$code = $curr\n"; } else { print "'$code' is not a valid currency code!\n"; }
currency2code()
function only returns one code, so
you might not get back the code you expected.
Michael Hennecke <hennecke@rz.uni-karlsruhe.de> and Neil Bowers <neil@bowers.com>
Copyright (C) 2002, Neil Bowers.
Copyright (c) 2001 Michael Hennecke and Canon Research Centre Europe (CRE).
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Locale::Currency - ISO three letter codes for currency identification |