Debian Codegraph @

lib/Finance/Quote/Currencies.pm

raw
1 # This program is free software; you can redistribute it and/or modify
2 # it under the terms of the GNU General Public License as published by
3 # the Free Software Foundation; either version 2 of the License, or
4 # (at your option) any later version.
5 #
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 # GNU General Public License for more details.
10 #
11 # You should have received a copy of the GNU General Public License
12 # along with this program; if not, write to the Free Software
13 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
14 # 02110-1301, USA
15 #
16 package Finance::Quote::Currencies;
17
18 use strict;
19 use warnings;
20 use utf8;
21
22 use constant DEBUG => $ENV{DEBUG};
23 use if DEBUG, 'Smart::Comments';
24 use if DEBUG, 'Data::Dumper::Perltidy';
25
26 use base 'Exporter';
27 use vars qw/@EXPORT_OK $CURRENCY_URL/;
28
29 use LWP::UserAgent;
30 use HTTP::Request::Common;
31 use HTML::TableExtract;
32 use Encode qw(decode);
33
34 our $VERSION = '1.71'; # VERSION
35
36 @EXPORT_OK = qw( known_currencies fetch_live_currencies );
37
38 $CURRENCY_URL = 'https://www.iban.com/currency-codes';
39
40 sub methods { return ( known_currencies => \&known_currencies
41 , fetch_live_currencies => \&fetch_live_currencies
42 );
43 }
44
45 sub labels { return () };
46
47 my %currencies = (
48
49 'AED' => {
50 'country' => ['UNITED ARAB EMIRATES (THE)'],
51 'name' => 'UAE Dirham',
52 'code' => 'AED',
53 'number' => '784'
54 },
55 'AFN' => {
56 'country' => ['AFGHANISTAN'],
57 'name' => 'Afghani',
58 'code' => 'AFN',
59 'number' => '971'
60 },
61 'ALL' => {
62 'country' => ['ALBANIA'],
63 'name' => 'Lek',
64 'code' => 'ALL',
65 'number' => '008'
66 },
67 'AMD' => {
68 'country' => ['ARMENIA'],
69 'name' => 'Armenian Dram',
70 'code' => 'AMD',
71 'number' => '051'
72 },
73 'ANG' => {
74 'country' => [
75 'CURAÇAO',
76 'SINT MAARTEN (DUTCH PART)'
77 ],
78 'name' => 'Netherlands Antillean Guilder',
79 'code' => 'ANG',
80 'number' => '532'
81 },
82 'AOA' => {
83 'country' => ['ANGOLA'],
84 'name' => 'Kwanza',
85 'code' => 'AOA',
86 'number' => '973'
87 },
88 'ARS' => {
89 'country' => ['ARGENTINA'],
90 'name' => 'Argentine Peso',
91 'code' => 'ARS',
92 'number' => '032'
93 },
94 'AUD' => {
95 'country' => [
96 'AUSTRALIA',
97 'CHRISTMAS ISLAND',
98 'COCOS (KEELING) ISLANDS (THE)',
99 'HEARD ISLAND AND McDONALD ISLANDS',
100 'KIRIBATI',
101 'NAURU',
102 'NORFOLK ISLAND',
103 'TUVALU'
104 ],
105 'name' => 'Australian Dollar',
106 'code' => 'AUD',
107 'number' => '036'
108 },
109 'AWG' => {
110 'country' => ['ARUBA'],
111 'name' => 'Aruban Florin',
112 'code' => 'AWG',
113 'number' => '533'
114 },
115 'AZN' => {
116 'country' => ['AZERBAIJAN'],
117 'name' => 'Azerbaijanian Manat',
118 'code' => 'AZN',
119 'number' => '944'
120 },
121 'BAM' => {
122 'country' => ['BOSNIA AND HERZEGOVINA'],
123 'name' => 'Convertible Mark',
124 'code' => 'BAM',
125 'number' => '977'
126 },
127 'BBD' => {
128 'country' => ['BARBADOS'],
129 'name' => 'Barbados Dollar',
130 'code' => 'BBD',
131 'number' => '052'
132 },
133 'BDT' => {
134 'country' => ['BANGLADESH'],
135 'name' => 'Taka',
136 'code' => 'BDT',
137 'number' => '050'
138 },
139 'BGN' => {
140 'country' => ['BULGARIA'],
141 'name' => 'Bulgarian Lev',
142 'code' => 'BGN',
143 'number' => '975'
144 },
145 'BHD' => {
146 'country' => ['BAHRAIN'],
147 'name' => 'Bahraini Dinar',
148 'code' => 'BHD',
149 'number' => '048'
150 },
151 'BIF' => {
152 'country' => ['BURUNDI'],
153 'name' => 'Burundi Franc',
154 'code' => 'BIF',
155 'number' => '108'
156 },
157 'BMD' => {
158 'country' => ['BERMUDA'],
159 'name' => 'Bermudian Dollar',
160 'code' => 'BMD',
161 'number' => '060'
162 },
163 'BND' => {
164 'country' => ['BRUNEI DARUSSALAM'],
165 'name' => 'Brunei Dollar',
166 'code' => 'BND',
167 'number' => '096'
168 },
169 'BOB' => {
170 'country' => ['BOLIVIA (PLURINATIONAL STATE OF)'],
171 'name' => 'Boliviano',
172 'code' => 'BOB',
173 'number' => '068'
174 },
175 'BOV' => {
176 'country' => ['BOLIVIA (PLURINATIONAL STATE OF)'],
177 'name' => 'Mvdol',
178 'code' => 'BOV',
179 'number' => '984'
180 },
181 'BRL' => {
182 'country' => ['BRAZIL'],
183 'name' => 'Brazilian Real',
184 'code' => 'BRL',
185 'number' => '986'
186 },
187 'BSD' => {
188 'country' => ['BAHAMAS (THE)'],
189 'name' => 'Bahamian Dollar',
190 'code' => 'BSD',
191 'number' => '044'
192 },
193 'BTN' => {
194 'country' => ['BHUTAN'],
195 'name' => 'Ngultrum',
196 'code' => 'BTN',
197 'number' => '064'
198 },
199 'BWP' => {
200 'country' => ['BOTSWANA'],
201 'name' => 'Pula',
202 'code' => 'BWP',
203 'number' => '072'
204 },
205 'BYN' => {
206 'country' => ['BELARUS'],
207 'name' => 'Belarussian Ruble',
208 'code' => 'BYN',
209 'number' => '933'
210 },
211 'BZD' => {
212 'country' => ['BELIZE'],
213 'name' => 'Belize Dollar',
214 'code' => 'BZD',
215 'number' => '084'
216 },
217 'CAD' => {
218 'country' => ['CANADA'],
219 'name' => 'Canadian Dollar',
220 'code' => 'CAD',
221 'number' => '124'
222 },
223 'CDF' => {
224 'country' => ['CONGO (THE DEMOCRATIC REPUBLIC OF THE)'],
225 'name' => 'Congolese Franc',
226 'code' => 'CDF',
227 'number' => '976'
228 },
229 'CHE' => {
230 'country' => ['SWITZERLAND'],
231 'name' => 'WIR Euro',
232 'code' => 'CHE',
233 'number' => '947'
234 },
235 'CHF' => {
236 'country' => [
237 'LIECHTENSTEIN',
238 'SWITZERLAND'
239 ],
240 'name' => 'Swiss Franc',
241 'code' => 'CHF',
242 'number' => '756'
243 },
244 'CHW' => {
245 'country' => ['SWITZERLAND'],
246 'name' => 'WIR Franc',
247 'code' => 'CHW',
248 'number' => '948'
249 },
250 'CLF' => {
251 'country' => ['CHILE'],
252 'name' => 'Unidad de Fomento',
253 'code' => 'CLF',
254 'number' => '990'
255 },
256 'CLP' => {
257 'country' => ['CHILE'],
258 'name' => 'Chilean Peso',
259 'code' => 'CLP',
260 'number' => '152'
261 },
262 'CNY' => {
263 'country' => ['CHINA'],
264 'name' => 'Yuan Renminbi',
265 'code' => 'CNY',
266 'number' => '156'
267 },
268 'COP' => {
269 'country' => ['COLOMBIA'],
270 'name' => 'Colombian Peso',
271 'code' => 'COP',
272 'number' => '170'
273 },
274 'COU' => {
275 'country' => ['COLOMBIA'],
276 'name' => 'Unidad de Valor Real',
277 'code' => 'COU',
278 'number' => '970'
279 },
280 'CRC' => {
281 'country' => ['COSTA RICA'],
282 'name' => 'Costa Rican Colon',
283 'code' => 'CRC',
284 'number' => '188'
285 },
286 'CUC' => {
287 'country' => ['CUBA'],
288 'name' => 'Peso Convertible',
289 'code' => 'CUC',
290 'number' => '931'
291 },
292 'CUP' => {
293 'country' => ['CUBA'],
294 'name' => 'Cuban Peso',
295 'code' => 'CUP',
296 'number' => '192'
297 },
298 'CVE' => {
299 'country' => ['CABO VERDE'],
300 'name' => 'Cabo Verde Escudo',
301 'code' => 'CVE',
302 'number' => '132'
303 },
304 'CZK' => {
305 'country' => ['CZECH REPUBLIC (THE)'],
306 'name' => 'Czech Koruna',
307 'code' => 'CZK',
308 'number' => '203'
309 },
310 'DJF' => {
311 'country' => ['DJIBOUTI'],
312 'name' => 'Djibouti Franc',
313 'code' => 'DJF',
314 'number' => '262'
315 },
316 'DKK' => {
317 'country' => [
318 'DENMARK',
319 'FAROE ISLANDS (THE)',
320 'GREENLAND'
321 ],
322 'name' => 'Danish Krone',
323 'code' => 'DKK',
324 'number' => '208'
325 },
326 'DOP' => {
327 'country' => ['DOMINICAN REPUBLIC (THE)'],
328 'name' => 'Dominican Peso',
329 'code' => 'DOP',
330 'number' => '214'
331 },
332 'DZD' => {
333 'country' => ['ALGERIA'],
334 'name' => 'Algerian Dinar',
335 'code' => 'DZD',
336 'number' => '012'
337 },
338 'EGP' => {
339 'country' => ['EGYPT'],
340 'name' => 'Egyptian Pound',
341 'code' => 'EGP',
342 'number' => '818'
343 },
344 'ERN' => {
345 'country' => ['ERITREA'],
346 'name' => 'Nakfa',
347 'code' => 'ERN',
348 'number' => '232'
349 },
350 'ETB' => {
351 'country' => ['ETHIOPIA'],
352 'name' => 'Ethiopian Birr',
353 'code' => 'ETB',
354 'number' => '230'
355 },
356 'EUR' => {
357 'country' => [
358 'ÅLAND ISLANDS',
359 'ANDORRA',
360 'AUSTRIA',
361 'BELGIUM',
362 'CROATIA',
363 'CYPRUS',
364 'ESTONIA',
365 'EUROPEAN UNION',
366 'FINLAND',
367 'FRANCE',
368 'FRENCH GUIANA',
369 'FRENCH SOUTHERN TERRITORIES (THE)',
370 'GERMANY',
371 'GREECE',
372 'GUADELOUPE',
373 'HOLY SEE (THE)',
374 'IRELAND',
375 'ITALY',
376 'LATVIA',
377 'LITHUANIA',
378 'LUXEMBOURG',
379 'MALTA',
380 'MARTINIQUE',
381 'MAYOTTE',
382 'MONACO',
383 'MONTENEGRO',
384 'NETHERLANDS (THE)',
385 'PORTUGAL',
386 'RÉUNION',
387 'SAINT BARTHÉLEMY',
388 'SAINT MARTIN (FRENCH PART)',
389 'SAINT PIERRE AND MIQUELON',
390 'SAN MARINO',
391 'SLOVAKIA',
392 'SLOVENIA',
393 'SPAIN'
394 ],
395 'name' => 'Euro',
396 'code' => 'EUR',
397 'number' => '978'
398 },
399 'FJD' => {
400 'country' => ['FIJI'],
401 'name' => 'Fiji Dollar',
402 'code' => 'FJD',
403 'number' => '242'
404 },
405 'FKP' => {
406 'country' => ['FALKLAND ISLANDS (THE) [MALVINAS]'],
407 'name' => 'Falkland Islands Pound',
408 'code' => 'FKP',
409 'number' => '238'
410 },
411 'GBP' => {
412 'country' => [
413 'GUERNSEY',
414 'ISLE OF MAN',
415 'JERSEY',
416 'UNITED KINGDOM OF GREAT BRITAIN AND NORTHERN IRELAND (THE)'
417 ],
418 'name' => 'Pound Sterling',
419 'code' => 'GBP',
420 'number' => '826'
421 },
422 'GEL' => {
423 'country' => ['GEORGIA'],
424 'name' => 'Lari',
425 'code' => 'GEL',
426 'number' => '981'
427 },
428 'GHS' => {
429 'country' => ['GHANA'],
430 'name' => 'Ghana Cedi',
431 'code' => 'GHS',
432 'number' => '936'
433 },
434 'GIP' => {
435 'country' => ['GIBRALTAR'],
436 'name' => 'Gibraltar Pound',
437 'code' => 'GIP',
438 'number' => '292'
439 },
440 'GMD' => {
441 'country' => ['GAMBIA (THE)'],
442 'name' => 'Dalasi',
443 'code' => 'GMD',
444 'number' => '270'
445 },
446 'GNF' => {
447 'country' => ['GUINEA'],
448 'name' => 'Guinea Franc',
449 'code' => 'GNF',
450 'number' => '324'
451 },
452 'GTQ' => {
453 'country' => ['GUATEMALA'],
454 'name' => 'Quetzal',
455 'code' => 'GTQ',
456 'number' => '320'
457 },
458 'GYD' => {
459 'country' => ['GUYANA'],
460 'name' => 'Guyana Dollar',
461 'code' => 'GYD',
462 'number' => '328'
463 },
464 'HKD' => {
465 'country' => ['HONG KONG'],
466 'name' => 'Hong Kong Dollar',
467 'code' => 'HKD',
468 'number' => '344'
469 },
470 'HNL' => {
471 'country' => ['HONDURAS'],
472 'name' => 'Lempira',
473 'code' => 'HNL',
474 'number' => '340'
475 },
476 'HTG' => {
477 'country' => ['HAITI'],
478 'name' => 'Gourde',
479 'code' => 'HTG',
480 'number' => '332'
481 },
482 'HUF' => {
483 'country' => ['HUNGARY'],
484 'name' => 'Forint',
485 'code' => 'HUF',
486 'number' => '348'
487 },
488 'IDR' => {
489 'country' => ['INDONESIA'],
490 'name' => 'Rupiah',
491 'code' => 'IDR',
492 'number' => '360'
493 },
494 'ILS' => {
495 'country' => ['ISRAEL'],
496 'name' => 'New Israeli Sheqel',
497 'code' => 'ILS',
498 'number' => '376'
499 },
500 'INR' => {
501 'country' => [
502 'BHUTAN',
503 'INDIA'
504 ],
505 'name' => 'Indian Rupee',
506 'code' => 'INR',
507 'number' => '356'
508 },
509 'IQD' => {
510 'country' => ['IRAQ'],
511 'name' => 'Iraqi Dinar',
512 'code' => 'IQD',
513 'number' => '368'
514 },
515 'IRR' => {
516 'country' => ['IRAN (ISLAMIC REPUBLIC OF)'],
517 'name' => 'Iranian Rial',
518 'code' => 'IRR',
519 'number' => '364'
520 },
521 'ISK' => {
522 'country' => ['ICELAND'],
523 'name' => 'Iceland Krona',
524 'code' => 'ISK',
525 'number' => '352'
526 },
527 'JMD' => {
528 'country' => ['JAMAICA'],
529 'name' => 'Jamaican Dollar',
530 'code' => 'JMD',
531 'number' => '388'
532 },
533 'JOD' => {
534 'country' => ['JORDAN'],
535 'name' => 'Jordanian Dinar',
536 'code' => 'JOD',
537 'number' => '400'
538 },
539 'JPY' => {
540 'country' => ['JAPAN'],
541 'name' => 'Yen',
542 'code' => 'JPY',
543 'number' => '392'
544 },
545 'KES' => {
546 'country' => ['KENYA'],
547 'name' => 'Kenyan Shilling',
548 'code' => 'KES',
549 'number' => '404'
550 },
551 'KGS' => {
552 'country' => ['KYRGYZSTAN'],
553 'name' => 'Som',
554 'code' => 'KGS',
555 'number' => '417'
556 },
557 'KHR' => {
558 'country' => ['CAMBODIA'],
559 'name' => 'Riel',
560 'code' => 'KHR',
561 'number' => '116'
562 },
563 'KMF' => {
564 'country' => ['COMOROS (THE)'],
565 'name' => 'Comoro Franc',
566 'code' => 'KMF',
567 'number' => '174'
568 },
569 'KPW' => {
570 'country' => ['KOREA (THE DEMOCRATIC PEOPLE’S REPUBLIC OF)'],
571 'name' => 'North Korean Won',
572 'code' => 'KPW',
573 'number' => '408'
574 },
575 'KRW' => {
576 'country' => ['KOREA (THE REPUBLIC OF)'],
577 'name' => 'Won',
578 'code' => 'KRW',
579 'number' => '410'
580 },
581 'KWD' => {
582 'country' => ['KUWAIT'],
583 'name' => 'Kuwaiti Dinar',
584 'code' => 'KWD',
585 'number' => '414'
586 },
587 'KYD' => {
588 'country' => ['CAYMAN ISLANDS (THE)'],
589 'name' => 'Cayman Islands Dollar',
590 'code' => 'KYD',
591 'number' => '136'
592 },
593 'KZT' => {
594 'country' => ['KAZAKHSTAN'],
595 'name' => 'Tenge',
596 'code' => 'KZT',
597 'number' => '398'
598 },
599 'LAK' => {
600 'country' => ['LAO PEOPLE’S DEMOCRATIC REPUBLIC (THE)'],
601 'name' => 'Kip',
602 'code' => 'LAK',
603 'number' => '418'
604 },
605 'LBP' => {
606 'country' => ['LEBANON'],
607 'name' => 'Lebanese Pound',
608 'code' => 'LBP',
609 'number' => '422'
610 },
611 'LKR' => {
612 'country' => ['SRI LANKA'],
613 'name' => 'Sri Lanka Rupee',
614 'code' => 'LKR',
615 'number' => '144'
616 },
617 'LRD' => {
618 'country' => ['LIBERIA'],
619 'name' => 'Liberian Dollar',
620 'code' => 'LRD',
621 'number' => '430'
622 },
623 'LSL' => {
624 'country' => ['LESOTHO'],
625 'name' => 'Loti',
626 'code' => 'LSL',
627 'number' => '426'
628 },
629 'LYD' => {
630 'country' => ['LIBYA'],
631 'name' => 'Libyan Dinar',
632 'code' => 'LYD',
633 'number' => '434'
634 },
635 'MAD' => {
636 'country' => [
637 'MOROCCO',
638 'WESTERN SAHARA'
639 ],
640 'name' => 'Moroccan Dirham',
641 'code' => 'MAD',
642 'number' => '504'
643 },
644 'MDL' => {
645 'country' => ['MOLDOVA (THE REPUBLIC OF)'],
646 'name' => 'Moldovan Leu',
647 'code' => 'MDL',
648 'number' => '498'
649 },
650 'MGA' => {
651 'country' => ['MADAGASCAR'],
652 'name' => 'Malagasy Ariary',
653 'code' => 'MGA',
654 'number' => '969'
655 },
656 'MKD' => {
657 'country' => ['REPUBLIC OF NORTH MACEDONIA'],
658 'name' => 'Denar',
659 'code' => 'MKD',
660 'number' => '807'
661 },
662 'MMK' => {
663 'country' => ['MYANMAR'],
664 'name' => 'Kyat',
665 'code' => 'MMK',
666 'number' => '104'
667 },
668 'MNT' => {
669 'country' => ['MONGOLIA'],
670 'name' => 'Tugrik',
671 'code' => 'MNT',
672 'number' => '496'
673 },
674 'MOP' => {
675 'country' => ['MACAO'],
676 'name' => 'Pataca',
677 'code' => 'MOP',
678 'number' => '446'
679 },
680 'MRU' => {
681 'country' => ['MAURITANIA'],
682 'name' => 'Ouguiya',
683 'code' => 'MRU',
684 'number' => '929'
685 },
686 'MUR' => {
687 'country' => ['MAURITIUS'],
688 'name' => 'Mauritius Rupee',
689 'code' => 'MUR',
690 'number' => '480'
691 },
692 'MVR' => {
693 'country' => ['MALDIVES'],
694 'name' => 'Rufiyaa',
695 'code' => 'MVR',
696 'number' => '462'
697 },
698 'MWK' => {
699 'country' => ['MALAWI'],
700 'name' => 'Kwacha',
701 'code' => 'MWK',
702 'number' => '454'
703 },
704 'MXN' => {
705 'country' => ['MEXICO'],
706 'name' => 'Mexican Peso',
707 'code' => 'MXN',
708 'number' => '484'
709 },
710 'MXV' => {
711 'country' => ['MEXICO'],
712 'name' => 'Mexican Unidad de Inversion (UDI)',
713 'code' => 'MXV',
714 'number' => '979'
715 },
716 'MYR' => {
717 'country' => ['MALAYSIA'],
718 'name' => 'Malaysian Ringgit',
719 'code' => 'MYR',
720 'number' => '458'
721 },
722 'MZN' => {
723 'country' => ['MOZAMBIQUE'],
724 'name' => 'Mozambique Metical',
725 'code' => 'MZN',
726 'number' => '943'
727 },
728 'NAD' => {
729 'country' => ['NAMIBIA'],
730 'name' => 'Namibia Dollar',
731 'code' => 'NAD',
732 'number' => '516'
733 },
734 'NGN' => {
735 'country' => ['NIGERIA'],
736 'name' => 'Naira',
737 'code' => 'NGN',
738 'number' => '566'
739 },
740 'NIO' => {
741 'country' => ['NICARAGUA'],
742 'name' => 'Cordoba Oro',
743 'code' => 'NIO',
744 'number' => '558'
745 },
746 'NOK' => {
747 'country' => [
748 'BOUVET ISLAND',
749 'NORWAY',
750 'SVALBARD AND JAN MAYEN'
751 ],
752 'name' => 'Norwegian Krone',
753 'code' => 'NOK',
754 'number' => '578'
755 },
756 'NPR' => {
757 'country' => ['NEPAL'],
758 'name' => 'Nepalese Rupee',
759 'code' => 'NPR',
760 'number' => '524'
761 },
762 'NZD' => {
763 'country' => [
764 'COOK ISLANDS (THE)',
765 'NEW ZEALAND',
766 'NIUE',
767 'PITCAIRN',
768 'TOKELAU'
769 ],
770 'name' => 'New Zealand Dollar',
771 'code' => 'NZD',
772 'number' => '554'
773 },
774 'OMR' => {
775 'country' => ['OMAN'],
776 'name' => 'Rial Omani',
777 'code' => 'OMR',
778 'number' => '512'
779 },
780 'PAB' => {
781 'country' => ['PANAMA'],
782 'name' => 'Balboa',
783 'code' => 'PAB',
784 'number' => '590'
785 },
786 'PEN' => {
787 'country' => ['PERU'],
788 'name' => 'Nuevo Sol',
789 'code' => 'PEN',
790 'number' => '604'
791 },
792 'PGK' => {
793 'country' => ['PAPUA NEW GUINEA'],
794 'name' => 'Kina',
795 'code' => 'PGK',
796 'number' => '598'
797 },
798 'PHP' => {
799 'country' => ['PHILIPPINES (THE)'],
800 'name' => 'Philippine Peso',
801 'code' => 'PHP',
802 'number' => '608'
803 },
804 'PKR' => {
805 'country' => ['PAKISTAN'],
806 'name' => 'Pakistan Rupee',
807 'code' => 'PKR',
808 'number' => '586'
809 },
810 'PLN' => {
811 'country' => ['POLAND'],
812 'name' => 'Zloty',
813 'code' => 'PLN',
814 'number' => '985'
815 },
816 'PYG' => {
817 'country' => ['PARAGUAY'],
818 'name' => 'Guarani',
819 'code' => 'PYG',
820 'number' => '600'
821 },
822 'QAR' => {
823 'country' => ['QATAR'],
824 'name' => 'Qatari Rial',
825 'code' => 'QAR',
826 'number' => '634'
827 },
828 'RON' => {
829 'country' => ['ROMANIA'],
830 'name' => 'Romanian Leu',
831 'code' => 'RON',
832 'number' => '946'
833 },
834 'RSD' => {
835 'country' => ['SERBIA'],
836 'name' => 'Serbian Dinar',
837 'code' => 'RSD',
838 'number' => '941'
839 },
840 'RUB' => {
841 'country' => ['RUSSIAN FEDERATION (THE)'],
842 'name' => 'Russian Ruble',
843 'code' => 'RUB',
844 'number' => '643'
845 },
846 'RWF' => {
847 'country' => ['RWANDA'],
848 'name' => 'Rwanda Franc',
849 'code' => 'RWF',
850 'number' => '646'
851 },
852 'SAR' => {
853 'country' => ['SAUDI ARABIA'],
854 'name' => 'Saudi Riyal',
855 'code' => 'SAR',
856 'number' => '682'
857 },
858 'SBD' => {
859 'country' => ['SOLOMON ISLANDS'],
860 'name' => 'Solomon Islands Dollar',
861 'code' => 'SBD',
862 'number' => '090'
863 },
864 'SCR' => {
865 'country' => ['SEYCHELLES'],
866 'name' => 'Seychelles Rupee',
867 'code' => 'SCR',
868 'number' => '690'
869 },
870 'SDG' => {
871 'country' => ['SUDAN (THE)'],
872 'name' => 'Sudanese Pound',
873 'code' => 'SDG',
874 'number' => '938'
875 },
876 'SEK' => {
877 'country' => ['SWEDEN'],
878 'name' => 'Swedish Krona',
879 'code' => 'SEK',
880 'number' => '752'
881 },
882 'SGD' => {
883 'country' => ['SINGAPORE'],
884 'name' => 'Singapore Dollar',
885 'code' => 'SGD',
886 'number' => '702'
887 },
888 'SHP' => {
889 'country' => ['SAINT HELENA, ASCENSION AND TRISTAN DA CUNHA'],
890 'name' => 'Saint Helena Pound',
891 'code' => 'SHP',
892 'number' => '654'
893 },
894 'SLE' => {
895 'country' => ['SIERRA LEONE'],
896 'name' => 'Leone',
897 'code' => 'SLE',
898 'number' => '925'
899 },
900 'SOS' => {
901 'country' => ['SOMALIA'],
902 'name' => 'Somali Shilling',
903 'code' => 'SOS',
904 'number' => '706'
905 },
906 'SRD' => {
907 'country' => ['SURINAME'],
908 'name' => 'Surinam Dollar',
909 'code' => 'SRD',
910 'number' => '968'
911 },
912 'SSP' => {
913 'country' => ['SOUTH SUDAN'],
914 'name' => 'South Sudanese Pound',
915 'code' => 'SSP',
916 'number' => '728'
917 },
918 'STN' => {
919 'country' => ['SAO TOME AND PRINCIPE'],
920 'name' => 'Dobra',
921 'code' => 'STN',
922 'number' => '930'
923 },
924 'SVC' => {
925 'country' => ['EL SALVADOR'],
926 'name' => 'El Salvador Colon',
927 'code' => 'SVC',
928 'number' => '222'
929 },
930 'SYP' => {
931 'country' => ['SYRIAN ARAB REPUBLIC'],
932 'name' => 'Syrian Pound',
933 'code' => 'SYP',
934 'number' => '760'
935 },
936 'SZL' => {
937 'country' => ['SWAZILAND'],
938 'name' => 'Lilangeni',
939 'code' => 'SZL',
940 'number' => '748'
941 },
942 'THB' => {
943 'country' => ['THAILAND'],
944 'name' => 'Baht',
945 'code' => 'THB',
946 'number' => '764'
947 },
948 'TJS' => {
949 'country' => ['TAJIKISTAN'],
950 'name' => 'Somoni',
951 'code' => 'TJS',
952 'number' => '972'
953 },
954 'TMT' => {
955 'country' => ['TURKMENISTAN'],
956 'name' => 'Turkmenistan New Manat',
957 'code' => 'TMT',
958 'number' => '934'
959 },
960 'TND' => {
961 'country' => ['TUNISIA'],
962 'name' => 'Tunisian Dinar',
963 'code' => 'TND',
964 'number' => '788'
965 },
966 'TOP' => {
967 'country' => ['TONGA'],
968 'name' => 'Pa’anga',
969 'code' => 'TOP',
970 'number' => '776'
971 },
972 'TRY' => {
973 'country' => ['TURKEY'],
974 'name' => 'Turkish Lira',
975 'code' => 'TRY',
976 'number' => '949'
977 },
978 'TTD' => {
979 'country' => ['TRINIDAD AND TOBAGO'],
980 'name' => 'Trinidad and Tobago Dollar',
981 'code' => 'TTD',
982 'number' => '780'
983 },
984 'TWD' => {
985 'country' => ['TAIWAN (PROVINCE OF CHINA)'],
986 'name' => 'New Taiwan Dollar',
987 'code' => 'TWD',
988 'number' => '901'
989 },
990 'TZS' => {
991 'country' => ['TANZANIA, UNITED REPUBLIC OF'],
992 'name' => 'Tanzanian Shilling',
993 'code' => 'TZS',
994 'number' => '834'
995 },
996 'UAH' => {
997 'country' => ['UKRAINE'],
998 'name' => 'Hryvnia',
999 'code' => 'UAH',
1000 'number' => '980'
1001 },
1002 'UGX' => {
1003 'country' => ['UGANDA'],
1004 'name' => 'Uganda Shilling',
1005 'code' => 'UGX',
1006 'number' => '800'
1007 },
1008 'USD' => {
1009 'country' => [
1010 'AMERICAN SAMOA',
1011 'BONAIRE, SINT EUSTATIUS AND SABA',
1012 'BRITISH INDIAN OCEAN TERRITORY (THE)',
1013 'ECUADOR',
1014 'EL SALVADOR',
1015 'GUAM',
1016 'HAITI',
1017 'MARSHALL ISLANDS (THE)',
1018 'MICRONESIA (FEDERATED STATES OF)',
1019 'NORTHERN MARIANA ISLANDS (THE)',
1020 'PALAU',
1021 'PANAMA',
1022 'PUERTO RICO',
1023 'TIMOR-LESTE',
1024 'TURKS AND CAICOS ISLANDS (THE)',
1025 'UNITED STATES MINOR OUTLYING ISLANDS (THE)',
1026 'UNITED STATES OF AMERICA (THE)',
1027 'VIRGIN ISLANDS (BRITISH)',
1028 'VIRGIN ISLANDS (U.S.)'
1029 ],
1030 'name' => 'US Dollar',
1031 'code' => 'USD',
1032 'number' => '840'
1033 },
1034 'USN' => {
1035 'country' => ['UNITED STATES OF AMERICA (THE)'],
1036 'name' => 'US Dollar (Next day)',
1037 'code' => 'USN',
1038 'number' => '997'
1039 },
1040 'UYI' => {
1041 'country' => ['URUGUAY'],
1042 'name' => 'Uruguay Peso en Unidades Indexadas (URUIURUI)',
1043 'code' => 'UYI',
1044 'number' => '940'
1045 },
1046 'UYU' => {
1047 'country' => ['URUGUAY'],
1048 'name' => 'Peso Uruguayo',
1049 'code' => 'UYU',
1050 'number' => '858'
1051 },
1052 'UZS' => {
1053 'country' => ['UZBEKISTAN'],
1054 'name' => 'Uzbekistan Sum',
1055 'code' => 'UZS',
1056 'number' => '860'
1057 },
1058 'VED' => {
1059 'country' => ['VENEZUELA (BOLIVARIAN REPUBLIC OF)'],
1060 'name' => 'Bolivar',
1061 'code' => 'VED',
1062 'number' => '926'
1063 },
1064 'VEF' => {
1065 'country' => ['VENEZUELA (BOLIVARIAN REPUBLIC OF)'],
1066 'name' => 'Bolivar',
1067 'code' => 'VEF',
1068 'number' => '937'
1069 },
1070 'VND' => {
1071 'country' => ['VIET NAM'],
1072 'name' => 'Dong',
1073 'code' => 'VND',
1074 'number' => '704'
1075 },
1076 'VUV' => {
1077 'country' => ['VANUATU'],
1078 'name' => 'Vatu',
1079 'code' => 'VUV',
1080 'number' => '548'
1081 },
1082 'WST' => {
1083 'country' => ['SAMOA'],
1084 'name' => 'Tala',
1085 'code' => 'WST',
1086 'number' => '882'
1087 },
1088 'XAF' => {
1089 'country' => [
1090 'CAMEROON',
1091 'CENTRAL AFRICAN REPUBLIC (THE)',
1092 'CHAD',
1093 'CONGO (THE)',
1094 'EQUATORIAL GUINEA',
1095 'GABON'
1096 ],
1097 'name' => 'CFA Franc BEAC',
1098 'code' => 'XAF',
1099 'number' => '950'
1100 },
1101 'XCD' => {
1102 'country' => [
1103 'ANGUILLA',
1104 'ANTIGUA AND BARBUDA',
1105 'DOMINICA',
1106 'GRENADA',
1107 'MONTSERRAT',
1108 'SAINT KITTS AND NEVIS',
1109 'SAINT LUCIA',
1110 'SAINT VINCENT AND THE GRENADINES'
1111 ],
1112 'name' => 'East Caribbean Dollar',
1113 'code' => 'XCD',
1114 'number' => '951'
1115 },
1116 'XDR' => {
1117 'country' => ['INTERNATIONAL MONETARY FUND (IMF) '],
1118 'name' => 'SDR (Special Drawing Right)',
1119 'code' => 'XDR',
1120 'number' => '960'
1121 },
1122 'XOF' => {
1123 'country' => [
1124 'BENIN',
1125 'BURKINA FASO',
1126 'CÔTE D\'IVOIRE',
1127 'GUINEA-BISSAU',
1128 'MALI',
1129 'NIGER (THE)',
1130 'SENEGAL',
1131 'TOGO'
1132 ],
1133 'name' => 'CFA Franc BCEAO',
1134 'code' => 'XOF',
1135 'number' => '952'
1136 },
1137 'XPF' => {
1138 'country' => [
1139 'FRENCH POLYNESIA',
1140 'NEW CALEDONIA',
1141 'WALLIS AND FUTUNA'
1142 ],
1143 'name' => 'CFP Franc',
1144 'code' => 'XPF',
1145 'number' => '953'
1146 },
1147 'XSU' => {
1148 'country' => ['SISTEMA UNITARIO DE COMPENSACION REGIONAL DE PAGOS "SUCRE"'],
1149 'name' => 'Sucre',
1150 'code' => 'XSU',
1151 'number' => '994'
1152 },
1153 'XUA' => {
1154 'country' => ['MEMBER COUNTRIES OF THE AFRICAN DEVELOPMENT BANK GROUP'],
1155 'name' => 'ADB Unit of Account',
1156 'code' => 'XUA',
1157 'number' => '965'
1158 },
1159 'YER' => {
1160 'country' => ['YEMEN'],
1161 'name' => 'Yemeni Rial',
1162 'code' => 'YER',
1163 'number' => '886'
1164 },
1165 'ZAR' => {
1166 'country' => [
1167 'LESOTHO',
1168 'NAMIBIA',
1169 'SOUTH AFRICA'
1170 ],
1171 'name' => 'Rand',
1172 'code' => 'ZAR',
1173 'number' => '710'
1174 },
1175 'ZMW' => {
1176 'country' => ['ZAMBIA'],
1177 'name' => 'Zambian Kwacha',
1178 'code' => 'ZMW',
1179 'number' => '967'
1180 },
1181 'ZWL' => {
1182 'country' => ['ZIMBABWE'],
1183 'name' => 'Zimbabwe Dollar',
1184 'code' => 'ZWL',
1185 'number' => '932'
1186 },
1187
1188 );
1189
1190 # =======================================================================
1191 # known_currencies (public function)
1192 #
1193 # This function returns the known currency list. This is based on the
1194 # cached currency list in this module. Use fetch_live_currencies for the
1195 # live list.
1196 sub known_currencies {
1197 return \%currencies;
1198 }
1199
1200 # =======================================================================
1201 # fetch_live_currencies (public function)
1202 #
1203 # This function retrieved the live currency list from the Yahoo Finance
1204 # website. This function should really only be used to test if the known
1205 # currency list in this module is out of date.
1206 sub fetch_live_currencies {
1207 ### [<now>] Calling fetch_live_currencies with URL: $CURRENCY_URL
1208 my $ua = LWP::UserAgent->new();
1209 my $reply = $ua->request(GET $CURRENCY_URL);
1210 return unless $reply->is_success;
1211
1212 my $te = HTML::TableExtract->new( headers => ['Country', 'Currency', 'Code', 'Number']);
1213 $te->parse(decode('UTF-8', $reply->content));
1214
1215 my $ts = $te->first_table_found || die 'Currency table not found';
1216 my %result = ();
1217 foreach my $row ($ts->rows) {
1218 my ($country, $currency, $code, $number) = @$row;
1219 next unless defined $code;
1220
1221 # some country names in the HTML source have multi-space breaks
1222 $country =~ s/ +/ /g;
1223
1224 if (exists $result{$code}) {
1225 push(@{$result{$code}->{'country'}}, $country);
1226 }
1227 else {
1228 $result{$code} = {'name' => $currency,
1229 'country' => [$country],
1230 'code' => $code,
1231 'number' => $number};
1232 }
1233 }
1234
1235 if (DEBUG) {
1236 $Data::Dumper::Sortkeys = 1;
1237 ### result: \%result
1238 }
1239
1240 return \%result;
1241 }
1242
1243 1;
1244
1245 =head1 NAME
1246
1247 Finance::Quote::Currencies - List of currencies from iban.com
1248
1249 =head1 SYNOPSIS
1250
1251 use Finance::Quote::Currencies;
1252
1253 my $currencies = Finance::Quote::Currencies::known_currencies();
1254
1255 # Grab the latest list
1256 my $live_currencies = Finance::Quote::Currencies::fetchive_currencies();
1257
1258 =head1 DESCRIPTION
1259
1260 This module provides a list of known currencies from iban.com.
1261
1262 known_currencies returns a cached currency information stored in this module.
1263
1264 fetch_live_currencies is a function that fetches the latest currency information.
1265
1266 Both functions return a hash
1267
1268 {CODE => {'name' => 'Currency Name',
1269 'country' => ['List of countries known to use this currency'],
1270 'number' => 'ISO 4217 currency code'}}
1271
1272 =head1 CACHE DATE
1273
1274 The currency list stored in this module was last copied from the live site Oct
1275 2020.
1276
1277 =head1 LICENSE
1278
1279 This program is free software; you can redistribute it and/or modify it under
1280 the terms of the GNU General Public License as published by the Free Software
1281 Foundation; either version 2 of the License, or (at your option) any later
1282 version.
1283
1284 Currency information fetched through this module is bound by terms and
1285 conditons available at https://www.iban.com/terms.
1286
1287 =head1 AUTHORS
1288
1289 Bradley Dean <[email protected]> - Original Yahoo version
1290
1291 =cut