1Countries(3) User Contributed Perl Documentation Countries(3)
2
3
4
6 Geography::Countries -- 2-letter, 3-letter, and numerical codes for
7 countries.
8
10 use Geography::Countries;
11
12 $country = country 'DE'; # 'Germany'
13 @list = country 666; # ('PM', 'SPM', 666,
14 # 'Saint Pierre and Miquelon', 1)
15
17 This module maps country names, and their 2-letter, 3-letter and numer‐
18 ical codes, as defined by the ISO-3166 maintenance agency [1], and
19 defined by the UNSD.
20
21 The "country" subroutine.
22
23 This subroutine is exported by default. It takes a 2-letter, 3-letter
24 or numerical code, or a country name as argument. In scalar context, it
25 will return the country name, in list context, it will return a list
26 consisting of the 2-letter code, the 3-letter code, the numerical code,
27 the country name, and a flag, which is explained below. Note that not
28 all countries have all 3 codes; if a code is unknown, the undefined
29 value is returned.
30
31 There are 3 categories of countries. The largest category are the cur‐
32 rent countries. Then there is a small set of countries that no longer
33 exist. The final set consists of areas consisting of multiple coun‐
34 tries, like Africa. No 2-letter or 3-letter codes are available for the
35 second two sets. (ISO 3166-3 [3] defines 4 letter codes for the set of
36 countries that no longer exist, but the author of this module was
37 unable to get her hands on that standard.) By default, "country" only
38 returns countries from the first set, but this can be changed by giving
39 "country" an optional second argument.
40
41 The module optionally exports the constants "CNT_F_REGULAR",
42 "CNT_F_OLD", "CNT_F_REGION" and "CNT_F_ANY". These constants can also
43 be important all at once by using the tag ":FLAGS". "CNT_F_ANY" is just
44 the binary or of the three other flags. The second argument of "coun‐
45 try" should be the binary or of a subset of the flags "CNT_F_REGULAR",
46 "CNT_F_OLD", and "CNT_F_REGION" - if no, or a false, second argument is
47 given, "CNT_F_REGULAR" is assumed. If "CNT_F_REGULAR" is set, regular
48 (current) countries will be returned; if "CNT_F_OLD" is set, old, no
49 longer existing, countries will be returned, while "CNT_F_REGION" is
50 used in case a region (not necessarely) a country might be returned.
51 If "country" is used in list context, the fifth returned element is one
52 of "CNT_F_REGULAR", "CNT_F_OLD" and "CNT_F_REGION", indicating whether
53 the result is a regular country, an old country, or a region.
54
55 In list context, "country" returns a 5 element list. To avoid having to
56 remember which element is in which index, the constants "CNT_I_CODE2",
57 "CNT_I_CODE3", "CNT_I_NUMCODE", "CNT_I_COUNTRY" and "CNT_I_FLAG" can be
58 imported. Those constants contain the indices of the 2-letter code, the
59 3-letter code, the numerical code, the country, and the flag explained
60 above, respectively. All index constants can be imported by using the
61 ":INDICES" tag.
62
63 The "code2", "code3", "numcode" and "countries" routines.
64
65 All known 2-letter codes, 3-letter codes, numerical codes and country
66 names can be returned by the routines "code2", "code3", "numcode" and
67 "countries". None of these methods is exported by default; all need to
68 be imported if one wants to use them. The tag ":LISTS" imports them
69 all. In scalar context, the number of known codes or countries is
70 returned.
71
73 The 2-letter codes come from the ISO 3166-1:1997 standard [2]. ISO 3166
74 bases its list of country names on the list of names published by the
75 United Nations. This list is published by the Statistical Division of
76 the United Nations [4]. The UNSD uses 3-letter codes, and numerical
77 codes [5]. The information about old countries [6] and regions [7] also
78 comes from the United Nations.
79
80 In a few cases, there was a conflict between the way how the United
81 Nations spelled a name, and how ISO 3166 spells it. In most cases, is
82 was word order (for instance whether The republic of should preceed the
83 name, or come after the name. A few cases had minor spelling varia‐
84 tions. In all such cases, the method in which the UN spelled the name
85 was choosen; ISO 3166 claims to take the names from the UN, so we con‐
86 sider the UN authoritative.
87
88 [1] ISO Maintenance Agency (ISO 3166/MA)
89 http://www.din.de/gremien/nas/nabd/iso3166ma/index.html.
90
91 [2] Country codes, http://www.din.de/gremien/nas/nabd/iso3166ma/codl‐
92 stp1.html, 7 September 1999.
93
94 [3] ISO 3166-3, Code for formerly used country names.
95 http://www.din.de/gremien/nas/nabd/iso3166ma/info_pt3.html.
96
97 [4] United Nations, Statistics Division.
98 http://www.un.org/Depts/unsd/statdiv.htm.
99
100 [5] Country or area codes in alphabetical order.
101 http://www.un.org/Depts/unsd/methods/m49alpha.htm, 26 August 1999.
102
103 [6] Codes added or changed. http://www.un.org/Depts/unsd/meth‐
104 ods/m49chang.htm, 26 August 1999.
105
106 [7] Geographical regions. http://www.un.org/Depts/unsd/meth‐
107 ods/m49regin.htm, 26 August 1999.
108
110 Looking up information using country names is far from perfect. Except
111 for case and the amount of white space, the exact name as it appears on
112 the list has to be given. USA will not return anything, but United
113 States will.
114
116 $Log: Countries.pm,v $
117 Revision 1.4 2003/01/26 18:19:07 abigail
118 Changed license, email address. Added installation section.
119
120 Revision 1.3 2003/01/26 18:12:10 abigail
121 Removed INIT{} from initializing code, as the INIT{} isn't run
122 when doing 'require'.
123
124 Revision 1.2 2000/09/05 18:22:01 abigail
125 Changed typo in "Federal Republic of Germany" (Dan Allen)
126 Changed layout of test.pl
127
128 Revision 1.1 1999/09/15 07:27:22 abigail
129 Initial revision
130
132 This package was written by Abigail, geometry-countries@abigail.nl
133
135 This package is copyright 1999-2003 by Abigail.
136
137 Permission is hereby granted, free of charge, to any person obtaining a
138 copy of this software and associated documentation files (the "Soft‐
139 ware"), to deal in the Software without restriction, including without
140 limitation the rights to use, copy, modify, merge, publish, distribute,
141 sublicense, and/or sell copies of the Software, and to permit persons
142 to whom the Software is furnished to do so, subject to the following
143 conditions:
144
145 The above copyright notice and this permission notice shall be included
146 in all copies or substantial portions of the Software.
147
148 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
149 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MER‐
150 CHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
151 NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
152 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
153 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
154 DEALINGS IN THE SOFTWARE.
155
157 To install this module type the following:
158
159 perl Makefile.PL
160 make
161 make test
162 make install
163
164
165
166perl v5.8.8 2003-01-26 Countries(3)