1Locale::Currency(3pm)  Perl Programmers Reference Guide  Locale::Currency(3pm)
2
3
4

NAME

6       Locale::Currency - ISO three letter codes for currency identification
7       (ISO 4217)
8

SYNOPSIS

10           use Locale::Currency;
11
12           $curr = code2currency('usd');     # $curr gets 'US Dollar'
13           $code = currency2code('Euro');    # $code gets 'eur'
14
15           @codes   = all_currency_codes();
16           @names   = all_currency_names();
17

DESCRIPTION

19       The "Locale::Currency" module provides access to the ISO three-letter
20       codes for identifying currencies and funds, as defined in ISO 4217.
21       You can either access the codes via the "conversion routines"
22       (described below), or with the two functions which return lists of all
23       currency codes or all currency names.
24
25       There are two special codes defined by the standard which aren't
26       understood by this module:
27
28       XTS Specifically reserved for testing purposes.
29
30       XXX For transactions where no currency is involved.
31

CONVERSION ROUTINES

33       There are two conversion routines: "code2currency()" and
34       "currency2code()".
35
36       code2currency()
37           This function takes a three letter currency code and returns a
38           string which contains the name of the currency identified. If the
39           code is not a valid currency code, as defined by ISO 4217, then
40           "undef" will be returned.
41
42               $curr = code2currency($code);
43
44       currency2code()
45           This function takes a currency name and returns the corresponding
46           three letter currency code, if such exists.  If the argument could
47           not be identified as a currency name, then "undef" will be
48           returned.
49
50               $code = currency2code('French Franc');
51
52           The case of the currency name is not important.  See the section
53           "KNOWN BUGS AND LIMITATIONS" below.
54

QUERY ROUTINES

56       There are two function which can be used to obtain a list of all
57       currency codes, or all currency names:
58
59       "all_currency_codes()"
60           Returns a list of all three-letter currency codes.  The codes are
61           guaranteed to be all lower-case, and not in any particular order.
62
63       "all_currency_names()"
64           Returns a list of all currency names for which there is a
65           corresponding three-letter currency code. The names are
66           capitalised, and not returned in any particular order.
67

EXAMPLES

69       The following example illustrates use of the "code2currency()"
70       function.  The user is prompted for a currency code, and then told the
71       corresponding currency name:
72
73           $| = 1;    # turn off buffering
74
75           print "Enter currency code: ";
76           chop($code = <STDIN>);
77           $curr = code2currency($code);
78           if (defined $curr)
79           {
80               print "$code = $curr\n";
81           }
82           else
83           {
84               print "'$code' is not a valid currency code!\n";
85           }
86

KNOWN BUGS AND LIMITATIONS

88       ·   In the current implementation, all data is read in when the module
89           is loaded, and then held in memory.  A lazy implementation would be
90           more memory friendly.
91
92       ·   This module also includes the special codes which are not for a
93           currency, such as Gold, Platinum, etc.  This might cause a problem
94           if you're using this module to display a list of currencies.  Let
95           Neil know if this does cause a problem, and we can do something
96           about it.
97
98       ·   ISO 4217 also defines a numeric code for each currency.  Currency
99           codes are not currently supported by this module, in the same way
100           Locale::Country supports multiple codesets.
101
102       ·   There are three cases where there is more than one code for the
103           same currency name.  Kwacha has two codes: mwk for Malawi, and zmk
104           for Zambia.  The Russian Ruble has two codes: rub and rur.  The
105           Belarussian Ruble has two codes: byr and byb.  The currency2code()
106           function only returns one code, so you might not get back the code
107           you expected.
108

SEE ALSO

110       Locale::Country
111           ISO codes for identification of country (ISO 3166).
112
113       Locale::Script
114           ISO codes for identification of written scripts (ISO 15924).
115
116       ISO 4217:1995
117           Code for the representation of currencies and funds.
118
119       http://www.bsi-global.com/iso4217currency
120           Official web page for the ISO 4217 maintenance agency.  This has
121           the latest list of codes, in MS Word format. Boo.
122

AUTHOR

124       Michael Hennecke <hennecke@rz.uni-karlsruhe.de> and Neil Bowers
125       <neil@bowers.com>
126
128       Copyright (C) 2002-2004, Neil Bowers.
129
130       Copyright (c) 2001 Michael Hennecke and Canon Research Centre Europe
131       (CRE).
132
133       This module is free software; you can redistribute it and/or modify it
134       under the same terms as Perl itself.
135
136
137
138perl v5.12.4                      2011-06-07             Locale::Currency(3pm)
Impressum