1*0Sstevel@tonic-gate# 2*0Sstevel@tonic-gate# Locale::Currency - ISO three letter codes for currency identification 3*0Sstevel@tonic-gate# (ISO 4217) 4*0Sstevel@tonic-gate# 5*0Sstevel@tonic-gate# $Id: Currency.pm,v 2.2 2002/07/10 16:33:27 neilb Exp $ 6*0Sstevel@tonic-gate# 7*0Sstevel@tonic-gate 8*0Sstevel@tonic-gatepackage Locale::Currency; 9*0Sstevel@tonic-gateuse strict; 10*0Sstevel@tonic-gaterequire 5.002; 11*0Sstevel@tonic-gate 12*0Sstevel@tonic-gaterequire Exporter; 13*0Sstevel@tonic-gate 14*0Sstevel@tonic-gate#----------------------------------------------------------------------- 15*0Sstevel@tonic-gate# Public Global Variables 16*0Sstevel@tonic-gate#----------------------------------------------------------------------- 17*0Sstevel@tonic-gateuse vars qw($VERSION @ISA @EXPORT); 18*0Sstevel@tonic-gate$VERSION = sprintf("%d.%02d", q$Revision: 2.21 $ =~ /(\d+)\.(\d+)/); 19*0Sstevel@tonic-gate@ISA = qw(Exporter); 20*0Sstevel@tonic-gate@EXPORT = qw(&code2currency ¤cy2code 21*0Sstevel@tonic-gate &all_currency_codes &all_currency_names ); 22*0Sstevel@tonic-gate 23*0Sstevel@tonic-gate#----------------------------------------------------------------------- 24*0Sstevel@tonic-gate# Private Global Variables 25*0Sstevel@tonic-gate#----------------------------------------------------------------------- 26*0Sstevel@tonic-gatemy %CODES = (); 27*0Sstevel@tonic-gatemy %CURRENCIES = (); 28*0Sstevel@tonic-gate 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate#======================================================================= 31*0Sstevel@tonic-gate# 32*0Sstevel@tonic-gate# code2currency( CODE ) 33*0Sstevel@tonic-gate# 34*0Sstevel@tonic-gate#======================================================================= 35*0Sstevel@tonic-gatesub code2currency 36*0Sstevel@tonic-gate{ 37*0Sstevel@tonic-gate my $code = shift; 38*0Sstevel@tonic-gate 39*0Sstevel@tonic-gate 40*0Sstevel@tonic-gate return undef unless defined $code; 41*0Sstevel@tonic-gate $code = lc($code); 42*0Sstevel@tonic-gate if (exists $CODES{$code}) 43*0Sstevel@tonic-gate { 44*0Sstevel@tonic-gate return $CODES{$code}; 45*0Sstevel@tonic-gate } 46*0Sstevel@tonic-gate else 47*0Sstevel@tonic-gate { 48*0Sstevel@tonic-gate #--------------------------------------------------------------- 49*0Sstevel@tonic-gate # no such currency code! 50*0Sstevel@tonic-gate #--------------------------------------------------------------- 51*0Sstevel@tonic-gate return undef; 52*0Sstevel@tonic-gate } 53*0Sstevel@tonic-gate} 54*0Sstevel@tonic-gate 55*0Sstevel@tonic-gate 56*0Sstevel@tonic-gate#======================================================================= 57*0Sstevel@tonic-gate# 58*0Sstevel@tonic-gate# currency2code ( CURRENCY ) 59*0Sstevel@tonic-gate# 60*0Sstevel@tonic-gate#======================================================================= 61*0Sstevel@tonic-gatesub currency2code 62*0Sstevel@tonic-gate{ 63*0Sstevel@tonic-gate my $curr = shift; 64*0Sstevel@tonic-gate 65*0Sstevel@tonic-gate 66*0Sstevel@tonic-gate return undef unless defined $curr; 67*0Sstevel@tonic-gate $curr = lc($curr); 68*0Sstevel@tonic-gate if (exists $CURRENCIES{$curr}) 69*0Sstevel@tonic-gate { 70*0Sstevel@tonic-gate return $CURRENCIES{$curr}; 71*0Sstevel@tonic-gate } 72*0Sstevel@tonic-gate else 73*0Sstevel@tonic-gate { 74*0Sstevel@tonic-gate #--------------------------------------------------------------- 75*0Sstevel@tonic-gate # no such currency! 76*0Sstevel@tonic-gate #--------------------------------------------------------------- 77*0Sstevel@tonic-gate return undef; 78*0Sstevel@tonic-gate } 79*0Sstevel@tonic-gate} 80*0Sstevel@tonic-gate 81*0Sstevel@tonic-gate 82*0Sstevel@tonic-gate#======================================================================= 83*0Sstevel@tonic-gate# 84*0Sstevel@tonic-gate# all_currency_codes() 85*0Sstevel@tonic-gate# 86*0Sstevel@tonic-gate#======================================================================= 87*0Sstevel@tonic-gatesub all_currency_codes 88*0Sstevel@tonic-gate{ 89*0Sstevel@tonic-gate return keys %CODES; 90*0Sstevel@tonic-gate} 91*0Sstevel@tonic-gate 92*0Sstevel@tonic-gate 93*0Sstevel@tonic-gate#======================================================================= 94*0Sstevel@tonic-gate# 95*0Sstevel@tonic-gate# all_currency_names() 96*0Sstevel@tonic-gate# 97*0Sstevel@tonic-gate#======================================================================= 98*0Sstevel@tonic-gatesub all_currency_names 99*0Sstevel@tonic-gate{ 100*0Sstevel@tonic-gate return values %CODES; 101*0Sstevel@tonic-gate} 102*0Sstevel@tonic-gate 103*0Sstevel@tonic-gate 104*0Sstevel@tonic-gate#======================================================================= 105*0Sstevel@tonic-gate# initialisation code - stuff the DATA into the CODES hash 106*0Sstevel@tonic-gate#======================================================================= 107*0Sstevel@tonic-gate{ 108*0Sstevel@tonic-gate my $code; 109*0Sstevel@tonic-gate my $currency; 110*0Sstevel@tonic-gate 111*0Sstevel@tonic-gate local $_; 112*0Sstevel@tonic-gate 113*0Sstevel@tonic-gate while (<DATA>) 114*0Sstevel@tonic-gate { 115*0Sstevel@tonic-gate next unless /\S/; 116*0Sstevel@tonic-gate chop; 117*0Sstevel@tonic-gate ($code, $currency) = split(/:/, $_, 2); 118*0Sstevel@tonic-gate $CODES{$code} = $currency; 119*0Sstevel@tonic-gate $CURRENCIES{"\L$currency"} = $code; 120*0Sstevel@tonic-gate } 121*0Sstevel@tonic-gate 122*0Sstevel@tonic-gate close(DATA); 123*0Sstevel@tonic-gate} 124*0Sstevel@tonic-gate 125*0Sstevel@tonic-gate1; 126*0Sstevel@tonic-gate 127*0Sstevel@tonic-gate__DATA__ 128*0Sstevel@tonic-gateadp:Andorran Peseta 129*0Sstevel@tonic-gateaed:UAE Dirham 130*0Sstevel@tonic-gateafa:Afghani 131*0Sstevel@tonic-gateall:Lek 132*0Sstevel@tonic-gateamd:Armenian Dram 133*0Sstevel@tonic-gateang:Netherlands Antillean Guilder 134*0Sstevel@tonic-gateaoa:Kwanza 135*0Sstevel@tonic-gateaon:New Kwanza 136*0Sstevel@tonic-gateaor:Kwanza Reajustado 137*0Sstevel@tonic-gatears:Argentine Peso 138*0Sstevel@tonic-gateats:Schilling 139*0Sstevel@tonic-gateaud:Australian Dollar 140*0Sstevel@tonic-gateawg:Aruban Guilder 141*0Sstevel@tonic-gateazm:Azerbaijanian Manat 142*0Sstevel@tonic-gate 143*0Sstevel@tonic-gatebam:Convertible Marks 144*0Sstevel@tonic-gatebbd:Barbados Dollar 145*0Sstevel@tonic-gatebdt:Taka 146*0Sstevel@tonic-gatebef:Belgian Franc 147*0Sstevel@tonic-gatebgl:Lev 148*0Sstevel@tonic-gatebgn:Bulgarian Lev 149*0Sstevel@tonic-gatebhd:Bahraini Dinar 150*0Sstevel@tonic-gatebhd:Dinar 151*0Sstevel@tonic-gatebif:Burundi Franc 152*0Sstevel@tonic-gatebmd:Bermudian Dollar 153*0Sstevel@tonic-gatebnd:Brunei Dollar 154*0Sstevel@tonic-gatebob:Boliviano 155*0Sstevel@tonic-gatebov:MVDol 156*0Sstevel@tonic-gatebrl:Brazilian Real 157*0Sstevel@tonic-gatebsd:Bahamian Dollar 158*0Sstevel@tonic-gatebtn:Ngultrum 159*0Sstevel@tonic-gatebwp:Pula 160*0Sstevel@tonic-gatebyb:Belarussian Ruble 161*0Sstevel@tonic-gatebyr:Belarussian Ruble 162*0Sstevel@tonic-gatebzd:Belize Dollar 163*0Sstevel@tonic-gate 164*0Sstevel@tonic-gatecad:Candian Dollar 165*0Sstevel@tonic-gatecdf:Franc Congolais 166*0Sstevel@tonic-gatechf:Swiss Franc 167*0Sstevel@tonic-gateclf:Unidades de Formento 168*0Sstevel@tonic-gateclp:Chilean Peso 169*0Sstevel@tonic-gatecny:Yuan Renminbi 170*0Sstevel@tonic-gatecop:Colombian Peso 171*0Sstevel@tonic-gatecrc:Costa Rican Colon 172*0Sstevel@tonic-gatecup:Cuban Peso 173*0Sstevel@tonic-gatecve:Cape Verde Escudo 174*0Sstevel@tonic-gatecyp:Cyprus Pound 175*0Sstevel@tonic-gateczk:Czech Koruna 176*0Sstevel@tonic-gate 177*0Sstevel@tonic-gatedem:German Mark 178*0Sstevel@tonic-gatedjf:Djibouti Franc 179*0Sstevel@tonic-gatedkk:Danish Krone 180*0Sstevel@tonic-gatedop:Dominican Peso 181*0Sstevel@tonic-gatedzd:Algerian Dinar 182*0Sstevel@tonic-gate 183*0Sstevel@tonic-gateecs:Sucre 184*0Sstevel@tonic-gateecv:Unidad de Valor Constante (UVC) 185*0Sstevel@tonic-gateeek:Kroon 186*0Sstevel@tonic-gateegp:Egyptian Pound 187*0Sstevel@tonic-gateern:Nakfa 188*0Sstevel@tonic-gateesp:Spanish Peseta 189*0Sstevel@tonic-gateetb:Ethiopian Birr 190*0Sstevel@tonic-gateeur:Euro 191*0Sstevel@tonic-gate 192*0Sstevel@tonic-gatefim:Markka 193*0Sstevel@tonic-gatefjd:Fiji Dollar 194*0Sstevel@tonic-gatefkp:Falkland Islands Pound 195*0Sstevel@tonic-gatefrf:French Franc 196*0Sstevel@tonic-gate 197*0Sstevel@tonic-gategbp:Pound Sterling 198*0Sstevel@tonic-gategel:Lari 199*0Sstevel@tonic-gateghc:Cedi 200*0Sstevel@tonic-gategip:Gibraltar Pound 201*0Sstevel@tonic-gategmd:Dalasi 202*0Sstevel@tonic-gategnf:Guinea Franc 203*0Sstevel@tonic-gategrd:Drachma 204*0Sstevel@tonic-gategtq:Quetzal 205*0Sstevel@tonic-gategwp:Guinea-Bissau Peso 206*0Sstevel@tonic-gategyd:Guyana Dollar 207*0Sstevel@tonic-gate 208*0Sstevel@tonic-gatehkd:Hong Kong Dollar 209*0Sstevel@tonic-gatehnl:Lempira 210*0Sstevel@tonic-gatehrk:Kuna 211*0Sstevel@tonic-gatehtg:Gourde 212*0Sstevel@tonic-gatehuf:Forint 213*0Sstevel@tonic-gate 214*0Sstevel@tonic-gateidr:Rupiah 215*0Sstevel@tonic-gateiep:Irish Pound 216*0Sstevel@tonic-gateils:Shekel 217*0Sstevel@tonic-gateinr:Indian Rupee 218*0Sstevel@tonic-gateiqd:Iraqi Dinar 219*0Sstevel@tonic-gateirr:Iranian Rial 220*0Sstevel@tonic-gateisk:Iceland Krona 221*0Sstevel@tonic-gateitl:Italian Lira 222*0Sstevel@tonic-gate 223*0Sstevel@tonic-gatejmd:Jamaican Dollar 224*0Sstevel@tonic-gatejod:Jordanian Dinar 225*0Sstevel@tonic-gatejpy:Yen 226*0Sstevel@tonic-gate 227*0Sstevel@tonic-gatekes:Kenyan Shilling 228*0Sstevel@tonic-gatekgs:Som 229*0Sstevel@tonic-gatekhr:Riel 230*0Sstevel@tonic-gatekmf:Comoro Franc 231*0Sstevel@tonic-gatekpw:North Korean Won 232*0Sstevel@tonic-gatekrw:Won 233*0Sstevel@tonic-gatekwd:Kuwaiti Dinar 234*0Sstevel@tonic-gatekyd:Cayman Islands Dollar 235*0Sstevel@tonic-gatekzt:Tenge 236*0Sstevel@tonic-gate 237*0Sstevel@tonic-gatelak:Kip 238*0Sstevel@tonic-gatelbp:Lebanese Pound 239*0Sstevel@tonic-gatelkr:Sri Lanka Rupee 240*0Sstevel@tonic-gatelrd:Liberian Dollar 241*0Sstevel@tonic-gatelsl:Loti 242*0Sstevel@tonic-gateltl:Lithuanian Litas 243*0Sstevel@tonic-gateluf:Luxembourg Franc 244*0Sstevel@tonic-gatelvl:Latvian Lats 245*0Sstevel@tonic-gatelyd:Libyan Dinar 246*0Sstevel@tonic-gate 247*0Sstevel@tonic-gatemad:Moroccan Dirham 248*0Sstevel@tonic-gatemdl:Moldovan Leu 249*0Sstevel@tonic-gatemgf:Malagasy Franc 250*0Sstevel@tonic-gatemkd:Denar 251*0Sstevel@tonic-gatemmk:Kyat 252*0Sstevel@tonic-gatemnt:Tugrik 253*0Sstevel@tonic-gatemop:Pataca 254*0Sstevel@tonic-gatemro:Ouguiya 255*0Sstevel@tonic-gatemtl:Maltese Lira 256*0Sstevel@tonic-gatemur:Mauritius Rupee 257*0Sstevel@tonic-gatemvr:Rufiyaa 258*0Sstevel@tonic-gatemwk:Kwacha 259*0Sstevel@tonic-gatemxn:Mexican Nuevo Peso 260*0Sstevel@tonic-gatemyr:Malaysian Ringgit 261*0Sstevel@tonic-gatemzm:Metical 262*0Sstevel@tonic-gate 263*0Sstevel@tonic-gatenad:Namibia Dollar 264*0Sstevel@tonic-gatengn:Naira 265*0Sstevel@tonic-gatenio:Cordoba Oro 266*0Sstevel@tonic-gatenlg:Netherlands Guilder 267*0Sstevel@tonic-gatenok:Norwegian Krone 268*0Sstevel@tonic-gatenpr:Nepalese Rupee 269*0Sstevel@tonic-gatenzd:New Zealand Dollar 270*0Sstevel@tonic-gate 271*0Sstevel@tonic-gateomr:Rial Omani 272*0Sstevel@tonic-gate 273*0Sstevel@tonic-gatepab:Balboa 274*0Sstevel@tonic-gatepen:Nuevo Sol 275*0Sstevel@tonic-gatepgk:Kina 276*0Sstevel@tonic-gatephp:Philippine Peso 277*0Sstevel@tonic-gatepkr:Pakistan Rupee 278*0Sstevel@tonic-gatepln:Zloty 279*0Sstevel@tonic-gatepte:Portuguese Escudo 280*0Sstevel@tonic-gatepyg:Guarani 281*0Sstevel@tonic-gate 282*0Sstevel@tonic-gateqar:Qatari Rial 283*0Sstevel@tonic-gate 284*0Sstevel@tonic-gaterol:Leu 285*0Sstevel@tonic-gaterub:Russian Ruble 286*0Sstevel@tonic-gaterur:Russian Ruble 287*0Sstevel@tonic-gaterwf:Rwanda Franc 288*0Sstevel@tonic-gate 289*0Sstevel@tonic-gatesar:Saudi Riyal 290*0Sstevel@tonic-gatesbd:Solomon Islands Dollar 291*0Sstevel@tonic-gatescr:Seychelles Rupee 292*0Sstevel@tonic-gatesdd:Sudanese Dinar 293*0Sstevel@tonic-gatesek:Swedish Krona 294*0Sstevel@tonic-gatesgd:Singapore Dollar 295*0Sstevel@tonic-gateshp:St. Helena Pound 296*0Sstevel@tonic-gatesit:Tolar 297*0Sstevel@tonic-gateskk:Slovak Koruna 298*0Sstevel@tonic-gatesll:Leone 299*0Sstevel@tonic-gatesos:Somali Shilling 300*0Sstevel@tonic-gatesrg:Surinam Guilder 301*0Sstevel@tonic-gatestd:Dobra 302*0Sstevel@tonic-gatesvc:El Salvador Colon 303*0Sstevel@tonic-gatesyp:Syrian Pound 304*0Sstevel@tonic-gateszl:Lilangeni 305*0Sstevel@tonic-gate 306*0Sstevel@tonic-gatethb:Baht 307*0Sstevel@tonic-gatetjr:Tajik Ruble 308*0Sstevel@tonic-gatetmm:Manat 309*0Sstevel@tonic-gatetnd:Tunisian Dollar 310*0Sstevel@tonic-gatetop:Pa'anga 311*0Sstevel@tonic-gatetpe:Timor Escudo 312*0Sstevel@tonic-gatetrl:Turkish Lira 313*0Sstevel@tonic-gatettd:Trinidad and Tobago Dollar 314*0Sstevel@tonic-gatetwd:New Taiwan Dollar 315*0Sstevel@tonic-gatetzs:Tanzanian Shilling 316*0Sstevel@tonic-gate 317*0Sstevel@tonic-gateuah:Hryvnia 318*0Sstevel@tonic-gateuak:Karbovanets 319*0Sstevel@tonic-gateugx:Uganda Shilling 320*0Sstevel@tonic-gateusd:US Dollar 321*0Sstevel@tonic-gateusn:US Dollar (Next day) 322*0Sstevel@tonic-gateuss:US Dollar (Same day) 323*0Sstevel@tonic-gateuyu:Peso Uruguayo 324*0Sstevel@tonic-gateuzs:Uzbekistan Sum 325*0Sstevel@tonic-gate 326*0Sstevel@tonic-gateveb:Bolivar 327*0Sstevel@tonic-gatevnd:Dong 328*0Sstevel@tonic-gatevuv:Vatu 329*0Sstevel@tonic-gate 330*0Sstevel@tonic-gatewst:Tala 331*0Sstevel@tonic-gate 332*0Sstevel@tonic-gatexaf:CFA Franc BEAC 333*0Sstevel@tonic-gatexag:Silver 334*0Sstevel@tonic-gatexau:Gold 335*0Sstevel@tonic-gatexba:European Composite Unit 336*0Sstevel@tonic-gatexbb:European Monetary Unit 337*0Sstevel@tonic-gatexbc:European Unit of Account 9 338*0Sstevel@tonic-gatexb5:European Unit of Account 17 339*0Sstevel@tonic-gatexcd:East Caribbean Dollar 340*0Sstevel@tonic-gatexdr:SDR 341*0Sstevel@tonic-gatexeu:ECU (until 1998-12-31) 342*0Sstevel@tonic-gatexfu:UIC-Franc 343*0Sstevel@tonic-gatexfo:Gold-Franc 344*0Sstevel@tonic-gatexof:CFA Franc BCEAO 345*0Sstevel@tonic-gatexpd:Palladium 346*0Sstevel@tonic-gatexpf:CFP Franc 347*0Sstevel@tonic-gatexpt:Platinum 348*0Sstevel@tonic-gate 349*0Sstevel@tonic-gateyer:Yemeni Rial 350*0Sstevel@tonic-gateyum:New Dinar 351*0Sstevel@tonic-gate 352*0Sstevel@tonic-gatezal:Financial Rand 353*0Sstevel@tonic-gatezar:Rand 354*0Sstevel@tonic-gatezmk:Kwacha 355*0Sstevel@tonic-gatezrn:New Zaire 356*0Sstevel@tonic-gatezwd:Zimbabwe Dollar 357