4 Locale::Currency - ISO three letter codes for currency identification (ISO 4217)
10 $curr = code2currency('usd'); # $curr gets 'US Dollar'
11 $code = currency2code('Euro'); # $code gets 'eur'
13 @codes = all_currency_codes();
14 @names = all_currency_names();
19 The C<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 L<conversion routines>
23 or with the two functions which return lists of all currency codes or
26 There are two special codes defined by the standard which aren't
27 understood by this module:
33 Specifically reserved for testing purposes.
37 For transactions where no currency is involved.
42 =head1 CONVERSION ROUTINES
44 There are two conversion routines: C<code2currency()> and C<currency2code()>.
50 This function takes a three letter currency code and returns a string
51 which contains the name of the currency identified. If the code is
52 not a valid currency code, as defined by ISO 4217, then C<undef>
55 $curr = code2currency($code);
59 This function takes a currency name and returns the corresponding
60 three letter currency code, if such exists.
61 If the argument could not be identified as a currency name,
62 then C<undef> will be returned.
64 $code = currency2code('French Franc');
66 The case of the currency name is not important.
67 See the section L<KNOWN BUGS AND LIMITATIONS> below.
74 There are two function which can be used to obtain a list of all
75 currency codes, or all currency names:
79 =item C<all_currency_codes()>
81 Returns a list of all three-letter currency codes.
82 The codes are guaranteed to be all lower-case,
83 and not in any particular order.
85 =item C<all_currency_names()>
87 Returns a list of all currency names for which there is a corresponding
88 three-letter currency code. The names are capitalised, and not returned
89 in any particular order.
96 The following example illustrates use of the C<code2currency()> function.
97 The user is prompted for a currency code, and then told the corresponding
100 $| = 1; # turn off buffering
102 print "Enter currency code: ";
103 chop($code = <STDIN>);
104 $curr = code2currency($code);
107 print "$code = $curr\n";
111 print "'$code' is not a valid currency code!\n";
114 =head1 KNOWN BUGS AND LIMITATIONS
120 In the current implementation, all data is read in when the
121 module is loaded, and then held in memory.
122 A lazy implementation would be more memory friendly.
126 This module also includes the special codes which are
127 not for a currency, such as Gold, Platinum, etc.
128 This might cause a problem if you're using this module
129 to display a list of currencies.
130 Let Neil know if this does cause a problem, and we can
131 do something about it.
135 ISO 4217 also defines a numeric code for each currency.
136 Currency codes are not currently supported by this module,
137 in the same way Locale::Country supports multiple codesets.
141 There are three cases where there is more than one
142 code for the same currency name.
143 Kwacha has two codes: mwk for Malawi, and zmk for Zambia.
144 The Russian Ruble has two codes: rub and rur.
145 The Belarussian Ruble has two codes: byr and byb.
146 The currency2code() function only returns one code, so
147 you might not get back the code you expected.
155 =item Locale::Country
157 ISO codes for identification of country (ISO 3166).
161 ISO codes for identification of written scripts (ISO 15924).
165 Code for the representation of currencies and funds.
167 =item http://www.bsi-global.com/iso4217currency
169 Official web page for the ISO 4217 maintenance agency.
170 This has the latest list of codes, in MS Word format. Boo.
176 Michael Hennecke E<lt>hennecke@rz.uni-karlsruhe.deE<gt>
178 Neil Bowers E<lt>neil@bowers.comE<gt>
182 Copyright (C) 2002, Neil Bowers.
184 Copyright (c) 2001 Michael Hennecke and
185 Canon Research Centre Europe (CRE).
187 This module is free software; you can redistribute it and/or
188 modify it under the same terms as Perl itself.