MirBSD manpage: Locale::Currency(3p)

Locale::Currency(Perl Programmers Reference GLocale::Currency(3p)


     Locale::Currency - ISO three letter codes for currency iden-
     tification (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:

     XTS Specifically reserved for testing purposes.

     XXX For transactions where no currency is involved.


     There are two conversion routines: "code2currency()" and

         This function takes a three letter currency code and
         returns a string which contains the name of the currency
         identified. If the code is not a valid currency code, as
         defined by ISO 4217, then "undef" will be returned.

             $curr = code2currency($code);

         This function takes a currency name and returns the
         corresponding three letter currency code, if such
         exists. If the argument could not be identified as a
         currency name, then "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.

perl v5.8.8                2005-02-05                           1

Locale::Currency(Perl Programmers Reference GLocale::Currency(3p)


     There are two function which can be used to obtain a list of
     all currency codes, or all currency names:

         Returns a list of all three-letter currency codes. The
         codes are guaranteed to be all lower-case, and not in
         any particular order.

         Returns a list of all currency names for which there is
         a corresponding three-letter currency code. The names
         are capitalised, and not returned in any particular


     The following example illustrates use of the
     "code2currency()" function. The user is prompted for a
     currency code, and then told the corresponding currency

         $| = 1;    # turn off buffering

         print "Enter currency code: ";
         chop($code = <STDIN>);
         $curr = code2currency($code);
         if (defined $curr)
             print "$code = $curr\n";
             print "'$code' is not a valid currency code!\n";


     +   In the current implementation, all data is read in when
         the module is loaded, and then held in memory. A lazy
         implementation would be more memory friendly.

     +   This module also includes the special codes which are
         not for a currency, such as Gold, Platinum, etc. This
         might cause a problem if you're using this module to
         display a list of currencies. Let Neil know if this does
         cause a problem, and we can do something about it.

     +   ISO 4217 also defines a numeric code for each currency.
         Currency codes are not currently supported by this
         module, in the same way Locale::Country supports multi-
         ple codesets.

     +   There are three cases where there is more than one code

perl v5.8.8                2005-02-05                           2

Locale::Currency(Perl Programmers Reference GLocale::Currency(3p)

         for the same currency name. Kwacha has two codes: mwk
         for Malawi, and zmk for Zambia. The Russian Ruble has
         two codes: rub and rur. The Belarussian Ruble has two
         codes: byr and byb. The currency2code() function only
         returns one code, so you might not get back the code you


         ISO codes for identification of country (ISO 3166).

         ISO codes for identification of written scripts (ISO

     ISO 4217:1995
         Code for the representation of currencies and funds.

         Official web page for the ISO 4217 maintenance agency.
         This has the latest list of codes, in MS Word format.


     Michael Hennecke <hennecke@rz.uni-karlsruhe.de> and Neil
     Bowers <neil@bowers.com>


     Copyright (C) 2002-2004, Neil Bowers.

     Copyright (c) 2001 Michael Hennecke and Canon Research Cen-
     tre Europe (CRE).

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

perl v5.8.8                2005-02-05                           3

Generated on 2022-12-24 01:00:14 by $MirOS: src/scripts/roff2htm,v 1.113 2022/12/21 23:14:31 tg Exp $ — This product includes material provided by mirabilos.

These manual pages and other documentation are copyrighted by their respective writers; their sources are available at the project’s CVSweb, AnonCVS and other mirrors. The rest is Copyright © 2002–2022 MirBSD.

This manual page’s HTML representation is supposed to be valid XHTML/1.1; if not, please send a bug report — diffs preferred.

Kontakt / Impressum & Datenschutzerklärung