Re: [perl #17174] perl 5.8.0 fails tests on NetBSD/Alpha
[p5sagit/p5-mst-13.2.git] / lib / Locale / Currency.pm
1 #
2 # Locale::Currency - ISO three letter codes for currency identification
3 #                    (ISO 4217)
4 #
5 # $Id: Currency.pm,v 2.2 2002/07/10 16:33:27 neilb Exp $
6 #
7
8 package Locale::Currency;
9 use strict;
10 require 5.002;
11
12 require Exporter;
13
14 #-----------------------------------------------------------------------
15 #       Public Global Variables
16 #-----------------------------------------------------------------------
17 use vars qw($VERSION @ISA @EXPORT);
18 $VERSION      = sprintf("%d.%02d", q$Revision: 2.2 $ =~ /(\d+)\.(\d+)/);
19 @ISA          = qw(Exporter);
20 @EXPORT       = qw(&code2currency &currency2code
21                    &all_currency_codes &all_currency_names );
22
23 #-----------------------------------------------------------------------
24 #       Private Global Variables
25 #-----------------------------------------------------------------------
26 my %CODES      = ();
27 my %CURRENCIES = ();
28
29
30 #=======================================================================
31 #
32 # code2currency( CODE )
33 #
34 #=======================================================================
35 sub code2currency
36 {
37     my $code = shift;
38
39
40     return undef unless defined $code;
41     $code = lc($code);
42     if (exists $CODES{$code})
43     {
44         return $CODES{$code};
45     }
46     else
47     {
48         #---------------------------------------------------------------
49         # no such currency code!
50         #---------------------------------------------------------------
51         return undef;
52     }
53 }
54
55
56 #=======================================================================
57 #
58 # currency2code ( CURRENCY )
59 #
60 #=======================================================================
61 sub currency2code
62 {
63     my $curr = shift;
64
65
66     return undef unless defined $curr;
67     $curr = lc($curr);
68     if (exists $CURRENCIES{$curr})
69     {
70         return $CURRENCIES{$curr};
71     }
72     else
73     {
74         #---------------------------------------------------------------
75         # no such currency!
76         #---------------------------------------------------------------
77         return undef;
78     }
79 }
80
81
82 #=======================================================================
83 #
84 # all_currency_codes()
85 #
86 #=======================================================================
87 sub all_currency_codes
88 {
89     return keys %CODES;
90 }
91
92
93 #=======================================================================
94 #
95 # all_currency_names()
96 #
97 #=======================================================================
98 sub all_currency_names
99 {
100     return values %CODES;
101 }
102
103
104 #=======================================================================
105 # initialisation code - stuff the DATA into the CODES hash
106 #=======================================================================
107 {
108     my $code;
109     my $currency;
110
111
112     while (<DATA>)
113     {
114         next unless /\S/;
115         chop;
116         ($code, $currency) = split(/:/, $_, 2);
117         $CODES{$code} = $currency;
118         $CURRENCIES{"\L$currency"} = $code;
119     }
120
121     close(DATA);
122 }
123
124 1;
125
126 __DATA__
127 adp:Andorran Peseta
128 aed:UAE Dirham
129 afa:Afghani
130 all:Lek
131 amd:Armenian Dram
132 ang:Netherlands Antillean Guilder
133 aoa:Kwanza
134 aon:New Kwanza
135 aor:Kwanza Reajustado
136 ars:Argentine Peso
137 ats:Schilling
138 aud:Australian Dollar
139 awg:Aruban Guilder
140 azm:Azerbaijanian Manat
141
142 bam:Convertible Marks
143 bbd:Barbados Dollar
144 bdt:Taka
145 bef:Belgian Franc
146 bgl:Lev
147 bgn:Bulgarian Lev
148 bhd:Bahraini Dinar
149 bhd:Dinar
150 bif:Burundi Franc
151 bmd:Bermudian Dollar
152 bnd:Brunei Dollar
153 bob:Boliviano
154 bov:MVDol
155 brl:Brazilian Real
156 bsd:Bahamian Dollar
157 btn:Ngultrum
158 bwp:Pula
159 byb:Belarussian Ruble
160 byr:Belarussian Ruble
161 bzd:Belize Dollar
162
163 cad:Candian Dollar
164 cdf:Franc Congolais
165 chf:Swiss Franc
166 clf:Unidades de Formento
167 clp:Chilean Peso
168 cny:Yuan Renminbi
169 cop:Colombian Peso
170 crc:Costa Rican Colon
171 cup:Cuban Peso
172 cve:Cape Verde Escudo
173 cyp:Cyprus Pound
174 czk:Czech Koruna
175
176 dem:German Mark
177 djf:Djibouti Franc
178 dkk:Danish Krone
179 dop:Dominican Peso
180 dzd:Algerian Dinar
181
182 ecs:Sucre
183 ecv:Unidad de Valor Constante (UVC)
184 eek:Kroon
185 egp:Egyptian Pound
186 ern:Nakfa
187 esp:Spanish Peseta
188 etb:Ethiopian Birr
189 eur:Euro
190
191 fim:Markka
192 fjd:Fiji Dollar
193 fkp:Falkland Islands Pound
194 frf:French Franc
195
196 gbp:Pound Sterling
197 gel:Lari
198 ghc:Cedi
199 gip:Gibraltar Pound
200 gmd:Dalasi
201 gnf:Guinea Franc
202 grd:Drachma
203 gtq:Quetzal
204 gwp:Guinea-Bissau Peso
205 gyd:Guyana Dollar
206
207 hkd:Hong Kong Dollar
208 hnl:Lempira
209 hrk:Kuna
210 htg:Gourde
211 huf:Forint
212
213 idr:Rupiah
214 iep:Irish Pound
215 ils:Shekel
216 inr:Indian Rupee
217 iqd:Iraqi Dinar
218 irr:Iranian Rial
219 isk:Iceland Krona
220 itl:Italian Lira
221
222 jmd:Jamaican Dollar
223 jod:Jordanian Dinar
224 jpy:Yen
225
226 kes:Kenyan Shilling
227 kgs:Som
228 khr:Riel
229 kmf:Comoro Franc
230 kpw:North Korean Won
231 krw:Won
232 kwd:Kuwaiti Dinar
233 kyd:Cayman Islands Dollar
234 kzt:Tenge
235
236 lak:Kip
237 lbp:Lebanese Pound
238 lkr:Sri Lanka Rupee
239 lrd:Liberian Dollar
240 lsl:Loti
241 ltl:Lithuanian Litas
242 luf:Luxembourg Franc
243 lvl:Latvian Lats
244 lyd:Libyan Dinar
245
246 mad:Moroccan Dirham
247 mdl:Moldovan Leu
248 mgf:Malagasy Franc
249 mkd:Denar
250 mmk:Kyat
251 mnt:Tugrik
252 mop:Pataca
253 mro:Ouguiya
254 mtl:Maltese Lira
255 mur:Mauritius Rupee
256 mvr:Rufiyaa
257 mwk:Kwacha
258 mxn:Mexican Nuevo Peso
259 myr:Malaysian Ringgit
260 mzm:Metical
261
262 nad:Namibia Dollar
263 ngn:Naira
264 nio:Cordoba Oro
265 nlg:Netherlands Guilder
266 nok:Norwegian Krone
267 npr:Nepalese Rupee
268 nzd:New Zealand Dollar
269
270 omr:Rial Omani
271
272 pab:Balboa
273 pen:Nuevo Sol
274 pgk:Kina
275 php:Philippine Peso
276 pkr:Pakistan Rupee
277 pln:Zloty
278 pte:Portuguese Escudo
279 pyg:Guarani
280
281 qar:Qatari Rial
282
283 rol:Leu
284 rub:Russian Ruble
285 rur:Russian Ruble
286 rwf:Rwanda Franc
287
288 sar:Saudi Riyal
289 sbd:Solomon Islands Dollar
290 scr:Seychelles Rupee
291 sdd:Sudanese Dinar
292 sek:Swedish Krona
293 sgd:Singapore Dollar
294 shp:St. Helena Pound
295 sit:Tolar
296 skk:Slovak Koruna
297 sll:Leone
298 sos:Somali Shilling
299 srg:Surinam Guilder
300 std:Dobra
301 svc:El Salvador Colon
302 syp:Syrian Pound
303 szl:Lilangeni
304
305 thb:Baht
306 tjr:Tajik Ruble
307 tmm:Manat
308 tnd:Tunisian Dollar
309 top:Pa'anga
310 tpe:Timor Escudo
311 trl:Turkish Lira
312 ttd:Trinidad and Tobago Dollar
313 twd:New Taiwan Dollar
314 tzs:Tanzanian Shilling
315
316 uah:Hryvnia
317 uak:Karbovanets
318 ugx:Uganda Shilling
319 usd:US Dollar
320 usn:US Dollar (Next day)
321 uss:US Dollar (Same day)
322 uyu:Peso Uruguayo
323 uzs:Uzbekistan Sum
324
325 veb:Bolivar
326 vnd:Dong
327 vuv:Vatu
328
329 wst:Tala
330
331 xaf:CFA Franc BEAC
332 xag:Silver
333 xau:Gold
334 xba:European Composite Unit
335 xbb:European Monetary Unit
336 xbc:European Unit of Account 9
337 xb5:European Unit of Account 17
338 xcd:East Caribbean Dollar
339 xdr:SDR
340 xeu:ECU (until 1998-12-31)
341 xfu:UIC-Franc
342 xfo:Gold-Franc
343 xof:CFA Franc BCEAO
344 xpd:Palladium
345 xpf:CFP Franc
346 xpt:Platinum
347
348 yer:Yemeni Rial
349 yum:New Dinar
350
351 zal:Financial Rand
352 zar:Rand
353 zmk:Kwacha
354 zrn:New Zaire
355 zwd:Zimbabwe Dollar