File Coverage

blib/lib/Locale/Currency/Format.pm
Criterion Covered Total %
statement 113 155 72.9
branch 77 118 65.2
condition 27 44 61.3
subroutine 11 13 84.6
pod 7 11 63.6
total 235 341 68.9


line stmt bran cond sub pod time code
1             package Locale::Currency::Format;
2              
3             require 5.006_00;
4              
5 1     1   21472 use strict;
  1         2  
  1         34  
6              
7 1     1   6 use Exporter;
  1         2  
  1         4675  
8              
9             $Locale::Currency::Format::VERSION = '1.35';
10              
11             @Locale::Currency::Format::ISA = qw(Exporter);
12             @Locale::Currency::Format::EXPORT = qw(
13             currency_format
14             currency_name
15             currency_set
16             currency_symbol
17             decimal_precision
18             decimal_separator
19             thousands_separator
20             FMT_NOZEROS
21             FMT_STANDARD
22             FMT_COMMON
23             FMT_SYMBOL
24             FMT_HTML
25             FMT_NAME
26             SYM_UTF
27             SYM_HTML
28             );
29              
30             @Locale::Currency::Format::EXPORT_OK = qw($error);
31              
32             %Locale::Currency::Format::EXPORT_TAGS = (
33             DEFAULT => [@Locale::Currency::Format::EXPORT],
34             default => [@Locale::Currency::Format::EXPORT],
35             );
36              
37             $Locale::Currency::Format::error = q{};
38              
39             # Macros for format options
40             sub FMT_NOZEROS() { 0x0001 }
41             sub FMT_STANDARD() { 0x0002 }
42             sub FMT_SYMBOL() { 0x0004 }
43             sub FMT_COMMON() { 0x0008 }
44             sub FMT_HTML() { 0x0010 }
45             sub FMT_NAME() { 0x0020 }
46              
47             # Macros for symbol options
48             sub SYM_UTF() { 0x0001 }
49             sub SYM_HTML() { 0x0002 }
50              
51             # Constants
52             my $EMPTY = q{};
53             my $SPACE = q{ };
54              
55             # File variables
56             my ($name, $frac_len, $thou_sep, $dec_sep,
57             $space_sep, $utf_sym, $htm_sym, $com_sym, $pre) = (0..8);
58              
59             my %original;
60             my %currency;
61             my @currency_codes;
62              
63             *::_error = \$Locale::Currency::Format::error;
64              
65             sub currency_format {
66 10     10 1 24 my ($code, $amt, $style) = @_;
67              
68 10 100       30 if (!defined $amt) {
69 2         4 $::_error = 'Undefined currency amount';
70 2         8 return;
71             }
72              
73 8 50       19 if (!defined $code) {
74 0         0 $::_error = 'Undefined currency code';
75 0         0 return;
76             }
77              
78 8         11 my $ucc = uc $code;
79 8         15 my $cur = $currency{$ucc};
80 8 100       17 if (!$cur) {
81 1         2 $::_error = 'Invalid currency code';
82 1         4 return;
83             }
84              
85 7 100 50     34 $amt = format_number(
86             $amt,
87             $cur->[$frac_len] || 0, # round-off precision
88             $style ? !($style & 0x1) : 1, # trailing zero or no
89             $cur->[$thou_sep], # thousand separator
90             $cur->[$dec_sep] # decimal separator
91             );
92              
93 7 100       16 $style = $style ? $style & 0x00FE : FMT_STANDARD;
94              
95 7 50 66     100 return $style == FMT_SYMBOL && $cur->[$utf_sym]
    50 66        
    100 66        
    100          
    100          
    100          
    100          
96             ? join($cur->[$space_sep], $cur->[$pre] ? ($cur->[$utf_sym], $amt)
97             : ($amt, $cur->[$utf_sym]))
98             : $style == FMT_HTML && $cur->[$htm_sym]
99             ? join($cur->[$space_sep], $cur->[$pre] ? ($cur->[$htm_sym], $amt)
100             : ($amt, $cur->[$htm_sym]))
101             : $style == FMT_COMMON && $cur->[$com_sym]
102             ? join($cur->[$space_sep], $cur->[$pre] ? ($cur->[$com_sym], $amt)
103             : ($amt, $cur->[$com_sym]))
104             : $style == FMT_NAME
105             ? join($SPACE, $amt, $cur->[$name])
106             : join($SPACE, $amt, $ucc)
107             ;
108             }
109              
110             sub currency_symbol {
111 6     6 1 12 my ($code, $type) = @_;
112              
113 6 100       32 if (!defined $code) {
114 1         2 $::_error = 'Undefined currency code';
115 1         4 return;
116             }
117            
118 5 100       12 $type = SYM_UTF unless $type;
119 5 100 100     26 if ($type != SYM_HTML and $type != SYM_UTF) {
120 1         2 $::_error = 'Invalid symbol type';
121 1         4 return;
122             }
123              
124 4         9 my $cur = $currency{uc $code};
125 4 100       9 if (!$cur) {
126 1         1 $::_error = 'Invalid currency code';
127 1         4 return;
128             }
129              
130 3 100       9 my $sym = $type == SYM_UTF ? $cur->[$utf_sym] : $cur->[$htm_sym];
131 3 100       7 if (!$sym) {
132 1 50       5 $::_error = 'Non-existant currency'
133             . ($type == SYM_UTF ? ' UTF ' : ' HTML ')
134             . 'symbol';
135 1         4 return;
136             }
137              
138 2         8 return $sym;
139             }
140              
141             sub currency_name {
142 2     2 1 5 my ( $code ) = @_;
143              
144 2 50       6 if ( !defined $code ) {
145 0         0 $::_error = 'Undefined currency code';
146 0         0 return;
147             }
148              
149 2         6 my $cur = $currency{ uc $code };
150 2 50       6 if ( !$cur ) {
151 0         0 $::_error = 'Invalid currency code';
152 0         0 return;
153             }
154              
155 2         3 my $name = $cur->[0];
156 2 50       10 if ( !$name ) {
157 0         0 $::_error = 'Non-existant currency name';
158 0         0 return;
159             }
160 2         8 return $name;
161             }
162              
163             sub currency_list {
164 0     0 0 0 return \@currency_codes;
165             }
166              
167             sub decimal_precision {
168 2     2 1 5 my ($code) = @_;
169              
170 2 50       7 if (!defined $code) {
171 0         0 $::_error = 'Undefined currency code';
172 0         0 return;
173             }
174              
175 2         4 my $cur = $currency{uc $code};
176 2 50       6 if (!$cur) {
177 0         0 $::_error = 'Invalid currency code';
178 0         0 return;
179             }
180              
181 2         3 my $precision = $cur->[$frac_len];
182 2 50       6 if (!$precision) {
183 0         0 $::_error = 'Non-existant decimal precision';
184 0         0 return;
185             }
186              
187 2         8 return $precision;
188             }
189              
190             sub decimal_separator {
191 2     2 1 4 my ($code) = @_;
192              
193 2 50       6 if (!defined $code) {
194 0         0 $::_error = 'Undefined currency code';
195 0         0 return;
196             }
197              
198 2         5 my $cur = $currency{uc $code};
199 2 50       6 if (!$cur) {
200 0         0 $::_error = 'Invalid currency code';
201 0         0 return;
202             }
203              
204 2         4 my $separator = $cur->[$dec_sep];
205 2 50       5 if (!$separator) {
206 0         0 $::_error = 'Non-existant decimal separator';
207 0         0 return;
208             }
209              
210 2         7 return $separator;
211             }
212              
213             sub thousands_separator {
214 2     2 1 4 my ($code) = @_;
215              
216 2 50       6 if (!defined $code) {
217 0         0 $::_error = 'Undefined currency code';
218 0         0 return;
219             }
220              
221 2         5 my $cur = $currency{uc $code};
222 2 50       6 if (!$cur) {
223 0         0 $::_error = 'Invalid currency code';
224 0         0 return;
225             }
226              
227 2         4 my $separator = $cur->[$thou_sep];
228 2 50       5 if (!$separator) {
229 0         0 $::_error = 'Non-existant thousands separator';
230 0         0 return;
231             }
232              
233 2         12 return $separator;
234             }
235              
236             sub currency_set {
237 3     3 1 7 my ($code, $tmpl, $style) = @_;
238              
239 3 50       8 if (!$code) {
240 0         0 $::_error = 'Undefined currency code';
241 0         0 return;
242             }
243 3 50 33     14 if ($tmpl
      66        
244             and (!$style
245             or !grep { $style == $_ } (FMT_SYMBOL, FMT_HTML, FMT_COMMON))
246             ) {
247 0         0 $::_error = 'Format must be of FMT_SYMBOL, FMT_HTML, FMT_COMMON';
248 0         0 return;
249             }
250              
251 3         4 my $ucc = uc $code;
252 3         7 my $cur = $currency{$ucc};
253 3 50       8 if (!$cur) {
254 0         0 $::_error = 'Invalid currency code';
255 0         0 return;
256             }
257              
258 3 100       8 if (!$tmpl) {
259 1 50       4 $currency{$ucc} = $original{$ucc} if $original{$ucc};
260 1         38 @currency_codes = keys %currency;
261 1         12 return $ucc;
262             }
263              
264 2 50 66     23 if ($tmpl !~ m{ \A
      33        
265             ([^#]*) # 1 - preceding symbol (may contain space)
266             \# # followed by a #
267             ([^#]+) # 2 - thousand separator
268             \#{3} # followed by 3 #'s
269             (?: #
270             ([^#]+) # 3 - decimal separator
271             (\#+) # 4 - fractional
272             )* #
273             ([^#]*) # 5 - trailing symbol (may contain space)
274             \Z
275             }xms
276             or ($1 and $5)
277             ) {
278 0         0 $::_error = 'Irregular currency format';
279 0         0 return;
280             }
281              
282             # Let's save an original copy if it has yet been done
283 2 50       11 $original{$ucc} = [@$cur] unless $original{$ucc};
284              
285             # Set fields based on template
286 2 100 66     15 $cur->[$pre] = $1 ? 1 : 0 if $1 or $5;
    50          
287 2         6 $cur->[$thou_sep] = $2;
288 2   33     8 $cur->[$dec_sep ] = $3 || $EMPTY;
289 2 50       8 $cur->[$frac_len] = $4 ? length($4) : 0;
290 2 50 66     22 if (($1 || $5) =~ m{\A (\s*) (.+) (\s*) \Z}xms) {
291 2   66     11 $cur->[$space_sep] = $1 || $3;
292 2 50       28 if ($style == FMT_SYMBOL) {
    50          
    50          
293 0         0 $cur->[$utf_sym] = $2;
294             }
295             elsif ($style == FMT_HTML) {
296 0         0 $cur->[$htm_sym] = $2;
297             }
298             elsif ($style == FMT_COMMON) {
299 2         6 $cur->[$com_sym] = $2;
300             }
301             }
302 2         138 @currency_codes = keys %currency;
303 2         23 return $ucc;
304             }
305              
306             # These functions are copied directly out of Number::Format due to a bug that
307             # lets locale settings take higher precedence to user's specific manipulation.
308             # In addition, this will exclude the unnecessary POSIX module used by
309             # Number::Format.
310              
311             sub round {
312 7     7 0 9 my ($number, $precision) = @_;
313            
314 7 50       16 $precision = 2 unless defined $precision;
315 7 50       15 $number = 0 unless defined $number;
316              
317 7         8 my $sign = $number <=> 0;
318 7         10 my $multiplier = (10 ** $precision);
319 7         11 my $result = abs($number);
320 7         17 $result = int(($result * $multiplier) + .5000001) / $multiplier;
321 7 50       15 $result = -$result if $sign < 0;
322 7         12 return $result;
323             }
324              
325             sub format_number {
326 7     7 0 13 my ($number, $precision, $trailing_zeroes, $ksep, $dsep) = @_;
327              
328             # Set defaults and standardize number
329 7 50       15 $precision = 2 unless defined $precision;
330 7 50       14 $trailing_zeroes = 1 unless defined $trailing_zeroes;
331              
332             # Handle negative numbers
333 7         9 my $sign = $number <=> 0;
334 7 50       15 $number = abs($number) if $sign < 0;
335 7         15 $number = round($number, $precision); # round off $number
336              
337             # Split integer and decimal parts of the number and add commas
338 7         10 my $integer = int($number);
339 7         9 my $decimal;
340             # Note: In perl 5.6 and up, string representation of a number
341             # automagically includes the locale decimal point. This way we
342             # will detect the decimal part correctly as long as the decimal
343             # point is 1 character.
344 7 50       17 $decimal = substr($number, length($integer)+1)
345             if (length($integer) < length($number));
346 7 50       15 $decimal = $EMPTY unless defined $decimal;
347              
348             # Add trailing 0's if $trailing_zeroes is set.
349 7 100 66     40 $decimal .= '0'x( $precision - length($decimal) )
350             if $trailing_zeroes && $precision > length($decimal);
351              
352             # Add leading 0's so length($integer) is divisible by 3
353 7 50       25 $integer = '0'x(3 - (length($integer) % 3)).$integer
354             unless length($integer) % 3 == 0;
355              
356             # Split $integer into groups of 3 characters and insert commas
357 7         38 $integer = join($ksep, grep {$_ ne $EMPTY} split(/(...)/, $integer));
  28         60  
358              
359             # Strip off leading zeroes and/or comma
360 7         26 $integer =~ s/^0+//;
361 7 50       18 $integer = '0' if $integer eq $EMPTY;
362              
363             # Combine integer and decimal parts and return the result.
364 7 100 66     40 my $result = ((defined $decimal && length $decimal) ?
365             join($dsep, $integer, $decimal) :
366             $integer);
367              
368 7 50       20 return ($sign < 0) ? format_negative($result) : $result;
369             }
370              
371             sub format_negative {
372 0     0 0   my($number, $format) = @_;
373 0 0         $format = '-x' unless defined $format;
374 0           $number =~ s/^-//;
375 0           $format =~ s/x/$number/;
376 0           return $format;
377             }
378              
379              
380              
381             #===========================================================================
382             # ISO 4217 and common world currency symbols
383             #===========================================================================
384             # code => 0 1 2 3 4 5 6 7 8
385             # name frac_len thou_sep dec_sep space_sep utf_sym htm_sym com_sym pre
386             %currency = (
387             AED => ["UAE Dirham",2,",","."," ",$EMPTY,$EMPTY,"Dhs.",1],
388             AFA => ["Afghani",0,$EMPTY,$EMPTY,"\x{060B}","؋",,$EMPTY,$EMPTY],
389             ALL => ["Lek",2,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
390             AMD => ["Armenian Dram",2,",",".","",$EMPTY,$EMPTY,"AMD",0],
391             ANG => ["Antillian Guilder",2,".",","," ","\x{0192}","ƒ","NAf.",1],
392             AON => ["New Kwanza",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
393             ARS => ["Argentine Peso",2,".",",","","\x{20B1}","₱","\$",1],
394             ATS => ["Schilling",2,".",","," ",$EMPTY,$EMPTY,"öS",1],
395             AUD => ["Australian Dollar",2," ",".","","\x{0024}","$","\$",1],
396             AWG => ["Aruban Guilder",2,",","."," ","\x{0192}","ƒ","AWG",1],
397             AZN => ["Azerbaijanian Manat",2,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,"m",$EMPTY],
398             BAM => ["Convertible Marks",2,",",".","",$EMPTY,$EMPTY,"AZM",0],
399             BBD => ["Barbados Dollar",2,$EMPTY,$EMPTY,"","\x{0024}","$",$EMPTY,$EMPTY],
400             BDT => ["Taka",2,",","."," ",$EMPTY,$EMPTY,"Bt.",1],
401             BEF => ["Belgian Franc",0,".",""," ","\x{20A3}","₣","BEF",1],
402             BGN => ["Lev",2," ",","," ",$EMPTY,$EMPTY,"lv",0],
403             BHD => ["Bahraini Dinar",3,",","."," ",$EMPTY,$EMPTY,"BD",1],
404             BIF => ["Burundi Franc",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
405             BMD => ["Bermudian Dollar",2,",",".","","\x{0024}","$","\$",1],
406             BND => ["Brunei Dollar",2,",",".","","\x{0024}","$","\$",1],
407             BOB => ["Bolivian Boliviano",2,",",".","",$EMPTY,$EMPTY,"Bs",1],
408             BRL => ["Brazilian Real",2,".",","," ","\x{0052}\x{0024}","R\$","R\$",1],
409             BSD => ["Bahamian Dollar",2,",",".","","\x{0024}","$","\$",1],
410             BTN => ["Bhutan Ngultrum",2,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
411             BWP => ["Pula",2,",",".","",$EMPTY,$EMPTY,"P",1],
412             BYR => ["Belarussian Ruble",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
413             BZD => ["Belize Dollar",2,",",".","","\x{0024}","$","\$",1],
414             CAD => ["Canadian Dollar",2,",",".","","\x{0024}","$","\$",1],
415             CDF => ["Franc Congolais",2,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
416             CHF => ["Swiss Franc",2,"'","."," ",$EMPTY,$EMPTY,"SFr.",1],
417             CLP => ["Chilean Peso",0,".","","","\x{20B1}","₱","\$",1],
418             CNY => ["Yuan Renminbi",2,",",".","","\x{5713}","圓","Y",1],
419             COP => ["Colombian Peso",2,".",",","","\x{20B1}","₱","\$",1],
420             CRC => ["Costa Rican Colon",2,".",","," ","\x{20A1}","₡","₡",1],
421             CUP => ["Cuban Peso",2,",","."," ","\x{20B1}","₱","\$",1],
422             CVE => ["Cape Verde Escudo",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
423             CYP => ["Cyprus Pound",2,".",",","","\x{00A3}","£","£",1],
424             CZK => ["Czech Koruna",2,".",","," ",$EMPTY,$EMPTY,"Kc",0],
425             DEM => ["Deutsche Mark",2,".",",","",$EMPTY,$EMPTY,"DM",0],
426             DJF => ["Djibouti Franc",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
427             DKK => ["Danish Krone",2,".",",","",$EMPTY,$EMPTY,"kr.",1],
428             DOP => ["Dominican Peso",2,",","."," ","\x{20B1}","₱","\$",1],
429             DZD => ["Algerian Dinar",2,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
430             ECS => ["Sucre",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
431             EEK => ["Kroon",2," ",","," ",$EMPTY,$EMPTY,"EEK",0],
432             EGP => ["Egyptian Pound",2,",","."," ","\x{00A3}","£","L.E.",1],
433             ERN => ["Nakfa",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
434             ESP => ["Spanish Peseta",0,".",""," ","\x{20A7}","₧","Ptas",0],
435             ETB => ["Ethiopian Birr",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
436             EUR => ["Euro",2,".",",","","\x{20AC}","€","EUR",1],
437             FIM => ["Markka",2," ",","," ",$EMPTY,$EMPTY,"mk",0],
438             FJD => ["Fiji Dollar",0,$EMPTY,$EMPTY,"","\x{0024}","$",$EMPTY,$EMPTY],
439             FKP => ["Pound",0,$EMPTY,$EMPTY,"","\x{00A3}","£",$EMPTY,$EMPTY],
440             FRF => ["French Franc",2," ",","," ","\x{20A3}","₣","FRF",0],
441             GBP => ["Pound Sterling",2,",",".","","\x{00A3}","£","£",1],
442             GEL => ["Lari",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
443             GHS => ["Cedi",2,",",".","","\x{20B5}","₵","₵",1],
444             GIP => ["Gibraltar Pound",2,",",".","","\x{00A3}","£","£",1],
445             GMD => ["Dalasi",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
446             GNF => ["Guinea Franc",$EMPTY,$EMPTY,$EMPTY,$EMPTY,$EMPTY,$EMPTY,$EMPTY,$EMPTY],
447             GRD => ["Drachma",2,".",","," ","\x{20AF}","₯","GRD",0],
448             GTQ => ["Quetzal",2,",",".","",$EMPTY,$EMPTY,"Q.",1],
449             GWP => ["Guinea-Bissau Peso",$EMPTY,$EMPTY,$EMPTY,$EMPTY,$EMPTY,$EMPTY,$EMPTY,$EMPTY],
450             GYD => ["Guyana Dollar",0,$EMPTY,$EMPTY,"","\x{0024}","$",$EMPTY,$EMPTY],
451             HKD => ["Hong Kong Dollar",2,",",".","","\x{0024}","$","HK\$",1],
452             HNL => ["Lempira",2,",","."," ",$EMPTY,$EMPTY,"L",1],
453             HRK => ["Kuna",2,".",","," ",$EMPTY,$EMPTY,"kn",0],
454             HTG => ["Gourde",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
455             HUF => ["Forint",0,".",""," ",$EMPTY,$EMPTY,"Ft",0],
456             IDR => ["Rupiah",0,".","","",$EMPTY,$EMPTY,"Rp.",1],
457             IEP => ["Irish Pound",2,",",".","","\x{00A3}","£","£",1],
458             ILS => ["New Israeli Sheqel",2,",","."," ","\x{20AA}","₪","NIS",0],
459             INR => ["Indian Rupee",2,",",".","","\x{20A8}","₨","Rs.",1],
460             IQD => ["Iraqi Dinar",3,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
461             IRR => ["Iranian Rial",2,",","."," ","\x{FDFC}","﷼","Rls",1],
462             ISK => ["Iceland Krona",2,".",","," ",$EMPTY,$EMPTY,"kr",0],
463             ITL => ["Italian Lira",0,".",""," ","\x{20A4}","₤","L.",1],
464             JMD => ["Jamaican Dollar",2,",",".","","\x{0024}","$","\$",1],
465             JOD => ["Jordanian Dinar",3,",","."," ",$EMPTY,$EMPTY,"JD",1],
466             JPY => ["Yen",0,",","","","\x{00A5}","¥","¥",1],
467             KES => ["Kenyan Shilling",2,",",".","",$EMPTY,$EMPTY,"Kshs.",1],
468             KGS => ["Som",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
469             KHR => ["Riel",2,$EMPTY,$EMPTY,"","\x{17DB}","៛",$EMPTY,$EMPTY],
470             KMF => ["Comoro Franc",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
471             KPW => ["North Korean Won",0,$EMPTY,$EMPTY,"","\x{20A9}","₩",$EMPTY,$EMPTY],
472             KRW => ["Won",0,",","","","\x{20A9}","₩","\\",1],
473             KWD => ["Kuwaiti Dinar",3,",","."," ",$EMPTY,$EMPTY,"KD",1],
474             KYD => ["Cayman Islands Dollar",2,",",".","","\x{0024}","$","\$",1],
475             KZT => ["Tenge",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
476             LAK => ["Kip",0,$EMPTY,$EMPTY,"","\x{20AD}","₭",$EMPTY,$EMPTY],
477             LBP => ["Lebanese Pound",0," ","","","\x{00A3}","£","L.L.",0],
478             LKR => ["Sri Lanka Rupee",0,$EMPTY,$EMPTY,"","\x{0BF9}","௹",$EMPTY,$EMPTY],
479             LRD => ["Liberian Dollar",0,$EMPTY,$EMPTY,"","\x{0024}","$",$EMPTY,$EMPTY],
480             LSL => ["Lesotho Maloti",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
481             LTL => ["Lithuanian Litas",2," ",","," ",$EMPTY,$EMPTY,"Lt",0],
482             LUF => ["Luxembourg Franc",0,"'",""," ","\x{20A3}","₣","F",0],
483             LVL => ["Latvian Lats",2,",","."," ",$EMPTY,$EMPTY,"Ls",1],
484             LYD => ["Libyan Dinar",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
485             MAD => ["Moroccan Dirham",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
486             MDL => ["Moldovan Leu",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
487             MGF => ["Malagasy Franc",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
488             MKD => ["Denar",2,",","."," ",$EMPTY,$EMPTY,"MKD",0],
489             MMK => ["Kyat",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
490             MNT => ["Tugrik",0,$EMPTY,$EMPTY,"","\x{20AE}","₮",$EMPTY,$EMPTY],
491             MOP => ["Pataca",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
492             MRO => ["Ouguiya",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
493             MTL => ["Maltese Lira",2,",",".","","\x{20A4}","₤","Lm",1],
494             MUR => ["Mauritius Rupee",0,",","","","\x{20A8}","₨","Rs",1],
495             MVR => ["Rufiyaa",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
496             MWK => ["Kwacha",2,",",".","",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
497             MXN => ["Mexican Peso",2,",","."," ","\x{0024}","$","\$",1],
498             MYR => ["Malaysian Ringgit",2,",",".","",$EMPTY,$EMPTY,"RM",1],
499             MZN => ["Metical",2,".",","," ",$EMPTY,$EMPTY,"Mt",0],
500             NAD => ["Namibian Dollar",0,$EMPTY,$EMPTY,"","\x{0024}","$",$EMPTY,$EMPTY],
501             NGN => ["Naira",0,$EMPTY,$EMPTY,"","\x{20A6}","₦",$EMPTY,$EMPTY],
502             NIO => ["Cordoba Oro",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
503             NLG => ["Netherlands Guilder",2,".",","," ","\x{0192}","ƒ","f",1],
504             NOK => ["Norwegian Krone",2,".",","," ","kr","kr","kr",1],
505             NPR => ["Nepalese Rupee",2,",","."," ","\x{20A8}","₨","Rs.",1],
506             NZD => ["New Zealand Dollar",2,",",".","","\x{0024}","$","\$",1],
507             OMR => ["Rial Omani",3,",","."," ","\x{FDFC}","﷼","RO",1],
508             PAB => ["Balboa",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
509             PEN => ["Nuevo Sol",2,",","."," ","S/.","S/.","S/.",1],
510             PGK => ["Kina",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
511             PHP => ["Philippine Peso",2,",",".","","\x{20B1}","₱","PHP",1],
512             PKR => ["Pakistan Rupee",2,",",".","","\x{20A8}","₨","Rs.",1],
513             PLN => ["Zloty",2," ",","," ",$EMPTY,$EMPTY,"zl",0],
514             PTE => ["Portuguese Escudo",0,".",""," ",$EMPTY,$EMPTY,"Esc",0],
515             PYG => ["Guarani",0,$EMPTY,$EMPTY,"","\x{20B2}","₲","Gs.",$EMPTY],
516             QAR => ["Qatari Rial",0,$EMPTY,$EMPTY,"","\x{FDFC}","﷼",$EMPTY,$EMPTY],
517             RON => ["Leu",2,".",","," ",$EMPTY,$EMPTY,"lei",0],
518             RSD => ["Serbian Dinar",2,$EMPTY,$EMPTY,$EMPTY,$EMPTY,$EMPTY,"din",0],
519             RUB => ["Russian Ruble",2,".",",",$EMPTY,"\x{0440}\x{0443}\x{0431}","руб","RUB",1],
520             RWF => ["Rwanda Franc",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
521             SAC => ["S. African Rand Commerc.",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
522             SAR => ["Saudi Riyal",2,",","."," ","\x{FDFC}","﷼","SR",1],
523             SBD => ["Solomon Islands Dollar",0,$EMPTY,$EMPTY,"","\x{0024}","$",$EMPTY,$EMPTY],
524             SCR => ["Seychelles Rupee",0,$EMPTY,$EMPTY,"","\x{20A8}","₨",$EMPTY,$EMPTY],
525             SDG => ["Sudanese Dinar",$EMPTY,$EMPTY,$EMPTY,$EMPTY,$EMPTY,$EMPTY,"LSd",$EMPTY],
526             SDP => ["Sudanese Pound",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
527             SEK => ["Swedish Krona",2," ",","," ",$EMPTY,$EMPTY,"kr",0],
528             SGD => ["Singapore Dollar",2,",",".","","\x{0024}","$","\$",1],
529             SHP => ["St Helena Pound",0,$EMPTY,$EMPTY,"","\x{00A3}","£",$EMPTY,$EMPTY],
530             SIT => ["Tolar",2,".",","," ",$EMPTY,$EMPTY,"SIT",0],
531             SKK => ["Slovak Koruna",2," ",","," ",$EMPTY,$EMPTY,"Sk",0],
532             SLL => ["Leone",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
533             SOS => ["Somali Shilling",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
534             SRG => ["Surinam Guilder",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
535             STD => ["Dobra",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
536             SVC => ["El Salvador Colon",2,",",".","","\x{20A1}","₡","¢",1],
537             SYP => ["Syrian Pound",0,$EMPTY,$EMPTY,"","\x{00A3}","£",$EMPTY,$EMPTY],
538             SZL => ["Lilangeni",2,"",".","",$EMPTY,$EMPTY,"E",1],
539             THB => ["Baht",2,",","."," ","\x{0E3F}","฿","Bt",0],
540             TJR => ["Tajik Ruble",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
541             TJS => ["Somoni",$EMPTY,$EMPTY,$EMPTY,$EMPTY,$EMPTY,$EMPTY,$EMPTY,$EMPTY],
542             TMM => ["Manat",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
543             TND => ["Tunisian Dinar",3,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
544             TOP => ["Pa'anga",2,",","."," ",$EMPTY,$EMPTY,"\$",1],
545             TPE => ["Timor Escudo",$EMPTY,$EMPTY,$EMPTY,$EMPTY,$EMPTY,$EMPTY,$EMPTY,$EMPTY],
546             TRY => ["Turkish Lira",0,",","","","\x{20A4}","₤","TL",0],
547             TTD => ["Trinidad and Tobago Dollar",0,$EMPTY,$EMPTY,"","\x{0024}","$",$EMPTY,$EMPTY],
548             TWD => ["New Taiwan Dollar",0,$EMPTY,$EMPTY,"","\x{0024}","$",$EMPTY,$EMPTY],
549             TZS => ["Tanzanian Shilling",2,",","."," ",$EMPTY,$EMPTY,"TZs",0],
550             UAH => ["Hryvnia",2," ",",","","\x{20B4}","₴",$EMPTY,0],
551             UGX => ["Uganda Shilling",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
552             USD => ["US Dollar",2,",",".","","\x{0024}","$","\$",1],
553             UYU => ["Peso Uruguayo",2,".",",","","\x{20B1}","₱","\$",1],
554             UZS => ["Uzbekistan Sum",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
555             VEF => ["Bolivar",2,".",","," ",$EMPTY,$EMPTY,"Bs.F",1],
556             VND => ["Dong",2,".",","," ","\x{20AB}","₫","Dong",0],
557             VUV => ["Vatu",0,",","","",$EMPTY,$EMPTY,"VT",0],
558             WST => ["Tala",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
559             XAF => ["CFA Franc BEAC",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
560             XCD => ["East Caribbean Dollar",2,",",".","","\x{0024}","$","\$",1],
561             XOF => ["CFA Franc BCEAO",$EMPTY,$EMPTY,$EMPTY,$EMPTY,$EMPTY,$EMPTY,$EMPTY,$EMPTY],
562             XPF => ["CFP Franc",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
563             YER => ["Yemeni Rial",0,$EMPTY,$EMPTY,"","\x{FDFC}","﷼",$EMPTY,$EMPTY],
564             YUN => ["New Dinar",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
565             ZAR => ["Rand",2," ","."," ","\x{0052}","R","R",1],
566             ZMK => ["Kwacha",0,$EMPTY,$EMPTY,"",$EMPTY,$EMPTY,$EMPTY,$EMPTY],
567             ZRN => ["New Zaire",$EMPTY,$EMPTY,$EMPTY,$EMPTY,$EMPTY,$EMPTY,$EMPTY,$EMPTY],
568             ZWD => ["Zimbabwe Dollar ",2," ",".","","\x{0024}","$","Z\$",1],
569             );
570             @currency_codes = keys %currency;
571              
572             1;
573              
574             __END__