File Coverage

blib/lib/Finance/Quote/Currencies.pm
Criterion Covered Total %
statement 39 56 69.6
branch 0 6 0.0
condition 0 2 0.0
subroutine 15 16 93.7
pod 0 4 0.0
total 54 84 64.2


line stmt bran cond sub pod time code
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 6     6   108519 use strict;
  6         43  
  6         183  
19 6     6   33 use warnings;
  6         12  
  6         260  
20 6     6   627 use utf8;
  6         88  
  6         119  
21              
22 6     6   238 use constant DEBUG => $ENV{DEBUG};
  6         88  
  6         461  
23 6     6   674 use if DEBUG, 'Smart::Comments';
  6         34  
  6         78  
24 6     6   255 use if DEBUG, 'Data::Dumper::Perltidy';
  6         61  
  6         49  
25              
26 6     6   242 use base 'Exporter';
  6         78  
  6         1083  
27 6     6   47 use vars qw/@EXPORT_OK $CURRENCY_URL/;
  6         22  
  6         321  
28              
29 6     6   746 use LWP::UserAgent;
  6         54722  
  6         86  
30 6     6   694 use HTTP::Request::Common;
  6         2273  
  6         454  
31 6     6   648 use HTML::TableExtract;
  6         14907  
  6         46  
32 6     6   803 use Encode qw(decode);
  6         15215  
  6         16251  
33              
34             our $VERSION = '1.57_03'; # TRIAL VERSION
35              
36             @EXPORT_OK = qw( known_currencies fetch_live_currencies );
37              
38             $CURRENCY_URL = 'https://www.iban.com/currency-codes';
39              
40 5     5 0 38 sub methods { return ( known_currencies => \&known_currencies
41             , fetch_live_currencies => \&fetch_live_currencies
42             );
43             }
44              
45 5     5 0 24 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             'CYPRUS',
363             'ESTONIA',
364             'EUROPEAN UNION',
365             'FINLAND',
366             'FRANCE',
367             'FRENCH GUIANA',
368             'FRENCH SOUTHERN TERRITORIES (THE)',
369             'GERMANY',
370             'GREECE',
371             'GUADELOUPE',
372             'HOLY SEE (THE)',
373             'IRELAND',
374             'ITALY',
375             'LATVIA',
376             'LITHUANIA',
377             'LUXEMBOURG',
378             'MALTA',
379             'MARTINIQUE',
380             'MAYOTTE',
381             'MONACO',
382             'MONTENEGRO',
383             'NETHERLANDS (THE)',
384             'PORTUGAL',
385             'RÉUNION',
386             'SAINT BARTHÉLEMY',
387             'SAINT MARTIN (FRENCH PART)',
388             'SAINT PIERRE AND MIQUELON',
389             'SAN MARINO',
390             'SLOVAKIA',
391             'SLOVENIA',
392             'SPAIN'
393             ],
394             'name' => 'Euro',
395             'code' => 'EUR',
396             'number' => '978'
397             },
398             'FJD' => {
399             'country' => ['FIJI'],
400             'name' => 'Fiji Dollar',
401             'code' => 'FJD',
402             'number' => '242'
403             },
404             'FKP' => {
405             'country' => ['FALKLAND ISLANDS (THE) [MALVINAS]'],
406             'name' => 'Falkland Islands Pound',
407             'code' => 'FKP',
408             'number' => '238'
409             },
410             'GBP' => {
411             'country' => [
412             'GUERNSEY',
413             'ISLE OF MAN',
414             'JERSEY',
415             'UNITED KINGDOM OF GREAT BRITAIN AND NORTHERN IRELAND (THE)'
416             ],
417             'name' => 'Pound Sterling',
418             'code' => 'GBP',
419             'number' => '826'
420             },
421             'GEL' => {
422             'country' => ['GEORGIA'],
423             'name' => 'Lari',
424             'code' => 'GEL',
425             'number' => '981'
426             },
427             'GHS' => {
428             'country' => ['GHANA'],
429             'name' => 'Ghana Cedi',
430             'code' => 'GHS',
431             'number' => '936'
432             },
433             'GIP' => {
434             'country' => ['GIBRALTAR'],
435             'name' => 'Gibraltar Pound',
436             'code' => 'GIP',
437             'number' => '292'
438             },
439             'GMD' => {
440             'country' => ['GAMBIA (THE)'],
441             'name' => 'Dalasi',
442             'code' => 'GMD',
443             'number' => '270'
444             },
445             'GNF' => {
446             'country' => ['GUINEA'],
447             'name' => 'Guinea Franc',
448             'code' => 'GNF',
449             'number' => '324'
450             },
451             'GTQ' => {
452             'country' => ['GUATEMALA'],
453             'name' => 'Quetzal',
454             'code' => 'GTQ',
455             'number' => '320'
456             },
457             'GYD' => {
458             'country' => ['GUYANA'],
459             'name' => 'Guyana Dollar',
460             'code' => 'GYD',
461             'number' => '328'
462             },
463             'HKD' => {
464             'country' => ['HONG KONG'],
465             'name' => 'Hong Kong Dollar',
466             'code' => 'HKD',
467             'number' => '344'
468             },
469             'HNL' => {
470             'country' => ['HONDURAS'],
471             'name' => 'Lempira',
472             'code' => 'HNL',
473             'number' => '340'
474             },
475             'HRK' => {
476             'country' => ['CROATIA'],
477             'name' => 'Kuna',
478             'code' => 'HRK',
479             'number' => '191'
480             },
481             'HTG' => {
482             'country' => ['HAITI'],
483             'name' => 'Gourde',
484             'code' => 'HTG',
485             'number' => '332'
486             },
487             'HUF' => {
488             'country' => ['HUNGARY'],
489             'name' => 'Forint',
490             'code' => 'HUF',
491             'number' => '348'
492             },
493             'IDR' => {
494             'country' => ['INDONESIA'],
495             'name' => 'Rupiah',
496             'code' => 'IDR',
497             'number' => '360'
498             },
499             'ILS' => {
500             'country' => ['ISRAEL'],
501             'name' => 'New Israeli Sheqel',
502             'code' => 'ILS',
503             'number' => '376'
504             },
505             'INR' => {
506             'country' => [
507             'BHUTAN',
508             'INDIA'
509             ],
510             'name' => 'Indian Rupee',
511             'code' => 'INR',
512             'number' => '356'
513             },
514             'IQD' => {
515             'country' => ['IRAQ'],
516             'name' => 'Iraqi Dinar',
517             'code' => 'IQD',
518             'number' => '368'
519             },
520             'IRR' => {
521             'country' => ['IRAN (ISLAMIC REPUBLIC OF)'],
522             'name' => 'Iranian Rial',
523             'code' => 'IRR',
524             'number' => '364'
525             },
526             'ISK' => {
527             'country' => ['ICELAND'],
528             'name' => 'Iceland Krona',
529             'code' => 'ISK',
530             'number' => '352'
531             },
532             'JMD' => {
533             'country' => ['JAMAICA'],
534             'name' => 'Jamaican Dollar',
535             'code' => 'JMD',
536             'number' => '388'
537             },
538             'JOD' => {
539             'country' => ['JORDAN'],
540             'name' => 'Jordanian Dinar',
541             'code' => 'JOD',
542             'number' => '400'
543             },
544             'JPY' => {
545             'country' => ['JAPAN'],
546             'name' => 'Yen',
547             'code' => 'JPY',
548             'number' => '392'
549             },
550             'KES' => {
551             'country' => ['KENYA'],
552             'name' => 'Kenyan Shilling',
553             'code' => 'KES',
554             'number' => '404'
555             },
556             'KGS' => {
557             'country' => ['KYRGYZSTAN'],
558             'name' => 'Som',
559             'code' => 'KGS',
560             'number' => '417'
561             },
562             'KHR' => {
563             'country' => ['CAMBODIA'],
564             'name' => 'Riel',
565             'code' => 'KHR',
566             'number' => '116'
567             },
568             'KMF' => {
569             'country' => ['COMOROS (THE)'],
570             'name' => 'Comoro Franc',
571             'code' => 'KMF',
572             'number' => '174'
573             },
574             'KPW' => {
575             'country' => ['KOREA (THE DEMOCRATIC PEOPLE’S REPUBLIC OF)'],
576             'name' => 'North Korean Won',
577             'code' => 'KPW',
578             'number' => '408'
579             },
580             'KRW' => {
581             'country' => ['KOREA (THE REPUBLIC OF)'],
582             'name' => 'Won',
583             'code' => 'KRW',
584             'number' => '410'
585             },
586             'KWD' => {
587             'country' => ['KUWAIT'],
588             'name' => 'Kuwaiti Dinar',
589             'code' => 'KWD',
590             'number' => '414'
591             },
592             'KYD' => {
593             'country' => ['CAYMAN ISLANDS (THE)'],
594             'name' => 'Cayman Islands Dollar',
595             'code' => 'KYD',
596             'number' => '136'
597             },
598             'KZT' => {
599             'country' => ['KAZAKHSTAN'],
600             'name' => 'Tenge',
601             'code' => 'KZT',
602             'number' => '398'
603             },
604             'LAK' => {
605             'country' => ['LAO PEOPLE’S DEMOCRATIC REPUBLIC (THE)'],
606             'name' => 'Kip',
607             'code' => 'LAK',
608             'number' => '418'
609             },
610             'LBP' => {
611             'country' => ['LEBANON'],
612             'name' => 'Lebanese Pound',
613             'code' => 'LBP',
614             'number' => '422'
615             },
616             'LKR' => {
617             'country' => ['SRI LANKA'],
618             'name' => 'Sri Lanka Rupee',
619             'code' => 'LKR',
620             'number' => '144'
621             },
622             'LRD' => {
623             'country' => ['LIBERIA'],
624             'name' => 'Liberian Dollar',
625             'code' => 'LRD',
626             'number' => '430'
627             },
628             'LSL' => {
629             'country' => ['LESOTHO'],
630             'name' => 'Loti',
631             'code' => 'LSL',
632             'number' => '426'
633             },
634             'LYD' => {
635             'country' => ['LIBYA'],
636             'name' => 'Libyan Dinar',
637             'code' => 'LYD',
638             'number' => '434'
639             },
640             'MAD' => {
641             'country' => [
642             'MOROCCO',
643             'WESTERN SAHARA'
644             ],
645             'name' => 'Moroccan Dirham',
646             'code' => 'MAD',
647             'number' => '504'
648             },
649             'MDL' => {
650             'country' => ['MOLDOVA (THE REPUBLIC OF)'],
651             'name' => 'Moldovan Leu',
652             'code' => 'MDL',
653             'number' => '498'
654             },
655             'MGA' => {
656             'country' => ['MADAGASCAR'],
657             'name' => 'Malagasy Ariary',
658             'code' => 'MGA',
659             'number' => '969'
660             },
661             'MKD' => {
662             'country' => ['REPUBLIC OF NORTH MACEDONIA'],
663             'name' => 'Denar',
664             'code' => 'MKD',
665             'number' => '807'
666             },
667             'MMK' => {
668             'country' => ['MYANMAR'],
669             'name' => 'Kyat',
670             'code' => 'MMK',
671             'number' => '104'
672             },
673             'MNT' => {
674             'country' => ['MONGOLIA'],
675             'name' => 'Tugrik',
676             'code' => 'MNT',
677             'number' => '496'
678             },
679             'MOP' => {
680             'country' => ['MACAO'],
681             'name' => 'Pataca',
682             'code' => 'MOP',
683             'number' => '446'
684             },
685             'MRU' => {
686             'country' => ['MAURITANIA'],
687             'name' => 'Ouguiya',
688             'code' => 'MRU',
689             'number' => '929'
690             },
691             'MUR' => {
692             'country' => ['MAURITIUS'],
693             'name' => 'Mauritius Rupee',
694             'code' => 'MUR',
695             'number' => '480'
696             },
697             'MVR' => {
698             'country' => ['MALDIVES'],
699             'name' => 'Rufiyaa',
700             'code' => 'MVR',
701             'number' => '462'
702             },
703             'MWK' => {
704             'country' => ['MALAWI'],
705             'name' => 'Kwacha',
706             'code' => 'MWK',
707             'number' => '454'
708             },
709             'MXN' => {
710             'country' => ['MEXICO'],
711             'name' => 'Mexican Peso',
712             'code' => 'MXN',
713             'number' => '484'
714             },
715             'MXV' => {
716             'country' => ['MEXICO'],
717             'name' => 'Mexican Unidad de Inversion (UDI)',
718             'code' => 'MXV',
719             'number' => '979'
720             },
721             'MYR' => {
722             'country' => ['MALAYSIA'],
723             'name' => 'Malaysian Ringgit',
724             'code' => 'MYR',
725             'number' => '458'
726             },
727             'MZN' => {
728             'country' => ['MOZAMBIQUE'],
729             'name' => 'Mozambique Metical',
730             'code' => 'MZN',
731             'number' => '943'
732             },
733             'NAD' => {
734             'country' => ['NAMIBIA'],
735             'name' => 'Namibia Dollar',
736             'code' => 'NAD',
737             'number' => '516'
738             },
739             'NGN' => {
740             'country' => ['NIGERIA'],
741             'name' => 'Naira',
742             'code' => 'NGN',
743             'number' => '566'
744             },
745             'NIO' => {
746             'country' => ['NICARAGUA'],
747             'name' => 'Cordoba Oro',
748             'code' => 'NIO',
749             'number' => '558'
750             },
751             'NOK' => {
752             'country' => [
753             'BOUVET ISLAND',
754             'NORWAY',
755             'SVALBARD AND JAN MAYEN'
756             ],
757             'name' => 'Norwegian Krone',
758             'code' => 'NOK',
759             'number' => '578'
760             },
761             'NPR' => {
762             'country' => ['NEPAL'],
763             'name' => 'Nepalese Rupee',
764             'code' => 'NPR',
765             'number' => '524'
766             },
767             'NZD' => {
768             'country' => [
769             'COOK ISLANDS (THE)',
770             'NEW ZEALAND',
771             'NIUE',
772             'PITCAIRN',
773             'TOKELAU'
774             ],
775             'name' => 'New Zealand Dollar',
776             'code' => 'NZD',
777             'number' => '554'
778             },
779             'OMR' => {
780             'country' => ['OMAN'],
781             'name' => 'Rial Omani',
782             'code' => 'OMR',
783             'number' => '512'
784             },
785             'PAB' => {
786             'country' => ['PANAMA'],
787             'name' => 'Balboa',
788             'code' => 'PAB',
789             'number' => '590'
790             },
791             'PEN' => {
792             'country' => ['PERU'],
793             'name' => 'Nuevo Sol',
794             'code' => 'PEN',
795             'number' => '604'
796             },
797             'PGK' => {
798             'country' => ['PAPUA NEW GUINEA'],
799             'name' => 'Kina',
800             'code' => 'PGK',
801             'number' => '598'
802             },
803             'PHP' => {
804             'country' => ['PHILIPPINES (THE)'],
805             'name' => 'Philippine Peso',
806             'code' => 'PHP',
807             'number' => '608'
808             },
809             'PKR' => {
810             'country' => ['PAKISTAN'],
811             'name' => 'Pakistan Rupee',
812             'code' => 'PKR',
813             'number' => '586'
814             },
815             'PLN' => {
816             'country' => ['POLAND'],
817             'name' => 'Zloty',
818             'code' => 'PLN',
819             'number' => '985'
820             },
821             'PYG' => {
822             'country' => ['PARAGUAY'],
823             'name' => 'Guarani',
824             'code' => 'PYG',
825             'number' => '600'
826             },
827             'QAR' => {
828             'country' => ['QATAR'],
829             'name' => 'Qatari Rial',
830             'code' => 'QAR',
831             'number' => '634'
832             },
833             'RON' => {
834             'country' => ['ROMANIA'],
835             'name' => 'Romanian Leu',
836             'code' => 'RON',
837             'number' => '946'
838             },
839             'RSD' => {
840             'country' => ['SERBIA'],
841             'name' => 'Serbian Dinar',
842             'code' => 'RSD',
843             'number' => '941'
844             },
845             'RUB' => {
846             'country' => ['RUSSIAN FEDERATION (THE)'],
847             'name' => 'Russian Ruble',
848             'code' => 'RUB',
849             'number' => '643'
850             },
851             'RWF' => {
852             'country' => ['RWANDA'],
853             'name' => 'Rwanda Franc',
854             'code' => 'RWF',
855             'number' => '646'
856             },
857             'SAR' => {
858             'country' => ['SAUDI ARABIA'],
859             'name' => 'Saudi Riyal',
860             'code' => 'SAR',
861             'number' => '682'
862             },
863             'SBD' => {
864             'country' => ['SOLOMON ISLANDS'],
865             'name' => 'Solomon Islands Dollar',
866             'code' => 'SBD',
867             'number' => '090'
868             },
869             'SCR' => {
870             'country' => ['SEYCHELLES'],
871             'name' => 'Seychelles Rupee',
872             'code' => 'SCR',
873             'number' => '690'
874             },
875             'SDG' => {
876             'country' => ['SUDAN (THE)'],
877             'name' => 'Sudanese Pound',
878             'code' => 'SDG',
879             'number' => '938'
880             },
881             'SEK' => {
882             'country' => ['SWEDEN'],
883             'name' => 'Swedish Krona',
884             'code' => 'SEK',
885             'number' => '752'
886             },
887             'SGD' => {
888             'country' => ['SINGAPORE'],
889             'name' => 'Singapore Dollar',
890             'code' => 'SGD',
891             'number' => '702'
892             },
893             'SHP' => {
894             'country' => ['SAINT HELENA, ASCENSION AND TRISTAN DA CUNHA'],
895             'name' => 'Saint Helena Pound',
896             'code' => 'SHP',
897             'number' => '654'
898             },
899             'SLL' => {
900             'country' => ['SIERRA LEONE'],
901             'name' => 'Leone',
902             'code' => 'SLL',
903             'number' => '694'
904             },
905             'SOS' => {
906             'country' => ['SOMALIA'],
907             'name' => 'Somali Shilling',
908             'code' => 'SOS',
909             'number' => '706'
910             },
911             'SRD' => {
912             'country' => ['SURINAME'],
913             'name' => 'Surinam Dollar',
914             'code' => 'SRD',
915             'number' => '968'
916             },
917             'SSP' => {
918             'country' => ['SOUTH SUDAN'],
919             'name' => 'South Sudanese Pound',
920             'code' => 'SSP',
921             'number' => '728'
922             },
923             'STN' => {
924             'country' => ['SAO TOME AND PRINCIPE'],
925             'name' => 'Dobra',
926             'code' => 'STN',
927             'number' => '930'
928             },
929             'SVC' => {
930             'country' => ['EL SALVADOR'],
931             'name' => 'El Salvador Colon',
932             'code' => 'SVC',
933             'number' => '222'
934             },
935             'SYP' => {
936             'country' => ['SYRIAN ARAB REPUBLIC'],
937             'name' => 'Syrian Pound',
938             'code' => 'SYP',
939             'number' => '760'
940             },
941             'SZL' => {
942             'country' => ['SWAZILAND'],
943             'name' => 'Lilangeni',
944             'code' => 'SZL',
945             'number' => '748'
946             },
947             'THB' => {
948             'country' => ['THAILAND'],
949             'name' => 'Baht',
950             'code' => 'THB',
951             'number' => '764'
952             },
953             'TJS' => {
954             'country' => ['TAJIKISTAN'],
955             'name' => 'Somoni',
956             'code' => 'TJS',
957             'number' => '972'
958             },
959             'TMT' => {
960             'country' => ['TURKMENISTAN'],
961             'name' => 'Turkmenistan New Manat',
962             'code' => 'TMT',
963             'number' => '934'
964             },
965             'TND' => {
966             'country' => ['TUNISIA'],
967             'name' => 'Tunisian Dinar',
968             'code' => 'TND',
969             'number' => '788'
970             },
971             'TOP' => {
972             'country' => ['TONGA'],
973             'name' => 'Pa’anga',
974             'code' => 'TOP',
975             'number' => '776'
976             },
977             'TRY' => {
978             'country' => ['TURKEY'],
979             'name' => 'Turkish Lira',
980             'code' => 'TRY',
981             'number' => '949'
982             },
983             'TTD' => {
984             'country' => ['TRINIDAD AND TOBAGO'],
985             'name' => 'Trinidad and Tobago Dollar',
986             'code' => 'TTD',
987             'number' => '780'
988             },
989             'TWD' => {
990             'country' => ['TAIWAN (PROVINCE OF CHINA)'],
991             'name' => 'New Taiwan Dollar',
992             'code' => 'TWD',
993             'number' => '901'
994             },
995             'TZS' => {
996             'country' => ['TANZANIA, UNITED REPUBLIC OF'],
997             'name' => 'Tanzanian Shilling',
998             'code' => 'TZS',
999             'number' => '834'
1000             },
1001             'UAH' => {
1002             'country' => ['UKRAINE'],
1003             'name' => 'Hryvnia',
1004             'code' => 'UAH',
1005             'number' => '980'
1006             },
1007             'UGX' => {
1008             'country' => ['UGANDA'],
1009             'name' => 'Uganda Shilling',
1010             'code' => 'UGX',
1011             'number' => '800'
1012             },
1013             'USD' => {
1014             'country' => [
1015             'AMERICAN SAMOA',
1016             'BONAIRE, SINT EUSTATIUS AND SABA',
1017             'BRITISH INDIAN OCEAN TERRITORY (THE)',
1018             'ECUADOR',
1019             'EL SALVADOR',
1020             'GUAM',
1021             'HAITI',
1022             'MARSHALL ISLANDS (THE)',
1023             'MICRONESIA (FEDERATED STATES OF)',
1024             'NORTHERN MARIANA ISLANDS (THE)',
1025             'PALAU',
1026             'PANAMA',
1027             'PUERTO RICO',
1028             'TIMOR-LESTE',
1029             'TURKS AND CAICOS ISLANDS (THE)',
1030             'UNITED STATES MINOR OUTLYING ISLANDS (THE)',
1031             'UNITED STATES OF AMERICA (THE)',
1032             'VIRGIN ISLANDS (BRITISH)',
1033             'VIRGIN ISLANDS (U.S.)'
1034             ],
1035             'name' => 'US Dollar',
1036             'code' => 'USD',
1037             'number' => '840'
1038             },
1039             'USN' => {
1040             'country' => ['UNITED STATES OF AMERICA (THE)'],
1041             'name' => 'US Dollar (Next day)',
1042             'code' => 'USN',
1043             'number' => '997'
1044             },
1045             'UYI' => {
1046             'country' => ['URUGUAY'],
1047             'name' => 'Uruguay Peso en Unidades Indexadas (URUIURUI)',
1048             'code' => 'UYI',
1049             'number' => '940'
1050             },
1051             'UYU' => {
1052             'country' => ['URUGUAY'],
1053             'name' => 'Peso Uruguayo',
1054             'code' => 'UYU',
1055             'number' => '858'
1056             },
1057             'UZS' => {
1058             'country' => ['UZBEKISTAN'],
1059             'name' => 'Uzbekistan Sum',
1060             'code' => 'UZS',
1061             'number' => '860'
1062             },
1063             'VEF' => {
1064             'country' => ['VENEZUELA (BOLIVARIAN REPUBLIC OF)'],
1065             'name' => 'Bolivar',
1066             'code' => 'VEF',
1067             'number' => '937'
1068             },
1069             'VND' => {
1070             'country' => ['VIET NAM'],
1071             'name' => 'Dong',
1072             'code' => 'VND',
1073             'number' => '704'
1074             },
1075             'VUV' => {
1076             'country' => ['VANUATU'],
1077             'name' => 'Vatu',
1078             'code' => 'VUV',
1079             'number' => '548'
1080             },
1081             'WST' => {
1082             'country' => ['SAMOA'],
1083             'name' => 'Tala',
1084             'code' => 'WST',
1085             'number' => '882'
1086             },
1087             'XAF' => {
1088             'country' => [
1089             'CAMEROON',
1090             'CENTRAL AFRICAN REPUBLIC (THE)',
1091             'CHAD',
1092             'CONGO (THE)',
1093             'EQUATORIAL GUINEA',
1094             'GABON'
1095             ],
1096             'name' => 'CFA Franc BEAC',
1097             'code' => 'XAF',
1098             'number' => '950'
1099             },
1100             'XCD' => {
1101             'country' => [
1102             'ANGUILLA',
1103             'ANTIGUA AND BARBUDA',
1104             'DOMINICA',
1105             'GRENADA',
1106             'MONTSERRAT',
1107             'SAINT KITTS AND NEVIS',
1108             'SAINT LUCIA',
1109             'SAINT VINCENT AND THE GRENADINES'
1110             ],
1111             'name' => 'East Caribbean Dollar',
1112             'code' => 'XCD',
1113             'number' => '951'
1114             },
1115             'XDR' => {
1116             'country' => ['INTERNATIONAL MONETARY FUND (IMF) '],
1117             'name' => 'SDR (Special Drawing Right)',
1118             'code' => 'XDR',
1119             'number' => '960'
1120             },
1121             'XOF' => {
1122             'country' => [
1123             'BENIN',
1124             'BURKINA FASO',
1125             'CÔTE D\'IVOIRE',
1126             'GUINEA-BISSAU',
1127             'MALI',
1128             'NIGER (THE)',
1129             'SENEGAL',
1130             'TOGO'
1131             ],
1132             'name' => 'CFA Franc BCEAO',
1133             'code' => 'XOF',
1134             'number' => '952'
1135             },
1136             'XPF' => {
1137             'country' => [
1138             'FRENCH POLYNESIA',
1139             'NEW CALEDONIA',
1140             'WALLIS AND FUTUNA'
1141             ],
1142             'name' => 'CFP Franc',
1143             'code' => 'XPF',
1144             'number' => '953'
1145             },
1146             'XSU' => {
1147             'country' => ['SISTEMA UNITARIO DE COMPENSACION REGIONAL DE PAGOS "SUCRE"'],
1148             'name' => 'Sucre',
1149             'code' => 'XSU',
1150             'number' => '994'
1151             },
1152             'XUA' => {
1153             'country' => ['MEMBER COUNTRIES OF THE AFRICAN DEVELOPMENT BANK GROUP'],
1154             'name' => 'ADB Unit of Account',
1155             'code' => 'XUA',
1156             'number' => '965'
1157             },
1158             'YER' => {
1159             'country' => ['YEMEN'],
1160             'name' => 'Yemeni Rial',
1161             'code' => 'YER',
1162             'number' => '886'
1163             },
1164             'ZAR' => {
1165             'country' => [
1166             'LESOTHO',
1167             'NAMIBIA',
1168             'SOUTH AFRICA'
1169             ],
1170             'name' => 'Rand',
1171             'code' => 'ZAR',
1172             'number' => '710'
1173             },
1174             'ZMW' => {
1175             'country' => ['ZAMBIA'],
1176             'name' => 'Zambian Kwacha',
1177             'code' => 'ZMW',
1178             'number' => '967'
1179             },
1180             'ZWL' => {
1181             'country' => ['ZIMBABWE'],
1182             'name' => 'Zimbabwe Dollar',
1183             'code' => 'ZWL',
1184             'number' => '932'
1185             },
1186              
1187             );
1188              
1189             # =======================================================================
1190             # known_currencies (public function)
1191             #
1192             # This function returns the known currency list. This is based on the
1193             # cached currency list in this module. Use fetch_live_currencies for the
1194             # live list.
1195             sub known_currencies {
1196 6     6 0 13 return \%currencies;
1197             }
1198              
1199             # =======================================================================
1200             # fetch_live_currencies (public function)
1201             #
1202             # This function retrieved the live currency list from the Yahoo Finance
1203             # website. This function should really only be used to test if the known
1204             # currency list in this module is out of date.
1205             sub fetch_live_currencies {
1206             ### [<now>] Calling fetch_live_currencies with URL: $CURRENCY_URL
1207 0     0 0   my $ua = LWP::UserAgent->new();
1208 0           my $reply = $ua->request(GET $CURRENCY_URL);
1209 0 0         return unless $reply->is_success;
1210              
1211 0           my $te = HTML::TableExtract->new( headers => ['Country', 'Currency', 'Code', 'Number']);
1212 0           $te->parse(decode('UTF-8', $reply->content));
1213            
1214 0   0       my $ts = $te->first_table_found || die 'Currency table not found';
1215 0           my %result = ();
1216 0           foreach my $row ($ts->rows) {
1217 0           my ($country, $currency, $code, $number) = @$row;
1218 0 0         next unless defined $code;
1219              
1220             # some country names in the HTML source have multi-space breaks
1221 0           $country =~ s/ +/ /g;
1222            
1223 0 0         if (exists $result{$code}) {
1224 0           push(@{$result{$code}->{'country'}}, $country);
  0            
1225             }
1226             else {
1227 0           $result{$code} = {'name' => $currency,
1228             'country' => [$country],
1229             'code' => $code,
1230             'number' => $number};
1231             }
1232             }
1233              
1234 0           if (DEBUG) {
1235             $Data::Dumper::Sortkeys = 1;
1236             ### result: \%result
1237             }
1238              
1239 0           return \%result;
1240             }
1241              
1242             1;
1243              
1244             =head1 NAME
1245              
1246             Finance::Quote::Currencies - List of currencies from iban.com
1247              
1248             =head1 SYNOPSIS
1249              
1250             use Finance::Quote::Currencies;
1251              
1252             my $currencies = Finance::Quote::Currencies::known_currencies();
1253              
1254             # Grab the latest list
1255             my $live_currencies = Finance::Quote::Currencies::fetchive_currencies();
1256              
1257             =head1 DESCRIPTION
1258              
1259             This module provides a list of known currencies from iban.com.
1260              
1261             known_currencies returns a cached currency information stored in this module.
1262              
1263             fetch_live_currencies is a function that fetches the latest currency information.
1264              
1265             Both functions return a hash
1266              
1267             {CODE => {'name' => 'Currency Name',
1268             'country' => ['List of countries known to use this currency'],
1269             'number' => 'ISO 4217 currency code'}}
1270              
1271             =head1 CACHE DATE
1272              
1273             The currency list stored in this module was last copied from the live site Oct
1274             2020.
1275              
1276             =head1 LICENSE
1277              
1278             This program is free software; you can redistribute it and/or modify it under
1279             the terms of the GNU General Public License as published by the Free Software
1280             Foundation; either version 2 of the License, or (at your option) any later
1281             version.
1282              
1283             Currency information fetched through this module is bound by terms and
1284             conditons available at https://www.iban.com/terms.
1285              
1286             =head1 AUTHORS
1287              
1288             Bradley Dean <bjdean@bjdean.id.au> - Original Yahoo version
1289              
1290             =cut