1NAME 2 Geography::Countries - 2-letter, 3-letter, and numerical codes for 3 countries. 4 5SYNOPSIS 6 use Geography::Countries; 7 8 $country = country 'DE'; # 'Germany' 9 @list = country 666; # ('PM', 'SPM', 666, 10 # 'Saint Pierre and Miquelon', 1) 11 12DESCRIPTION 13 This module maps country names, and their 2-letter, 3-letter and 14 numerical codes, as defined by the ISO-3166 maintenance agency [1], and 15 defined by the UNSD. 16 17 The "country" subroutine. 18 This subroutine is exported by default. It takes a 2-letter, 3-letter or 19 numerical code, or a country name as argument. In scalar context, it 20 will return the country name, in list context, it will return a list 21 consisting of the 2-letter code, the 3-letter code, the numerical code, 22 the country name, and a flag, which is explained below. Note that not 23 all countries have all 3 codes; if a code is unknown, the undefined 24 value is returned. 25 26 There are 3 categories of countries. The largest category are the 27 current countries. Then there is a small set of countries that no longer 28 exist. The final set consists of areas consisting of multiple countries, 29 like *Africa*. No 2-letter or 3-letter codes are available for the 30 second two sets. (ISO 3166-3 [3] defines 4 letter codes for the set of 31 countries that no longer exist, but the author of this module was unable 32 to get her hands on that standard.) By default, "country" only returns 33 countries from the first set, but this can be changed by giving 34 "country" an optional second argument. 35 36 The module optionally exports the constants "CNT_F_REGULAR", 37 "CNT_F_OLD", "CNT_F_REGION" and "CNT_F_ANY". These constants can also be 38 important all at once by using the tag ":FLAGS". "CNT_F_ANY" is just the 39 binary or of the three other flags. The second argument of "country" 40 should be the binary or of a subset of the flags "CNT_F_REGULAR", 41 "CNT_F_OLD", and "CNT_F_REGION" - if no, or a false, second argument is 42 given, "CNT_F_REGULAR" is assumed. If "CNT_F_REGULAR" is set, regular 43 (current) countries will be returned; if "CNT_F_OLD" is set, old, no 44 longer existing, countries will be returned, while "CNT_F_REGION" is 45 used in case a region (not necessarely) a country might be returned. If 46 "country" is used in list context, the fifth returned element is one of 47 "CNT_F_REGULAR", "CNT_F_OLD" and "CNT_F_REGION", indicating whether the 48 result is a regular country, an old country, or a region. 49 50 In list context, "country" returns a 5 element list. To avoid having to 51 remember which element is in which index, the constants "CNT_I_CODE2", 52 "CNT_I_CODE3", "CNT_I_NUMCODE", "CNT_I_COUNTRY" and "CNT_I_FLAG" can be 53 imported. Those constants contain the indices of the 2-letter code, the 54 3-letter code, the numerical code, the country, and the flag explained 55 above, respectively. All index constants can be imported by using the 56 ":INDICES" tag. 57 58 The "code2", "code3", "numcode" and "countries" routines. 59 All known 2-letter codes, 3-letter codes, numerical codes and country 60 names can be returned by the routines "code2", "code3", "numcode" and 61 "countries". None of these methods is exported by default; all need to 62 be imported if one wants to use them. The tag ":LISTS" imports them all. 63 In scalar context, the number of known codes or countries is returned. 64 65REFERENCES 66 The 2-letter codes come from the ISO 3166-1:1997 standard [2]. ISO 3166 67 bases its list of country names on the list of names published by the 68 United Nations. This list is published by the Statistical Division of 69 the United Nations [4]. The UNSD uses 3-letter codes, and numerical 70 codes [5]. The information about old countries [6] and regions [7] also 71 comes from the United Nations. 72 73 In a few cases, there was a conflict between the way how the United 74 Nations spelled a name, and how ISO 3166 spells it. In most cases, is 75 was word order (for instance whether *The republic of* should preceed 76 the name, or come after the name. A few cases had minor spelling 77 variations. In all such cases, the method in which the UN spelled the 78 name was choosen; ISO 3166 claims to take the names from the UN, so we 79 consider the UN authoritative. 80 81 [1] ISO Maintenance Agency (ISO 3166/MA) 82 *http://www.din.de/gremien/nas/nabd/iso3166ma/index.html*. 83 84 [2] *Country codes*, 85 *http://www.din.de/gremien/nas/nabd/iso3166ma/codlstp1.html*, 7 86 September 1999. 87 88 [3] ISO 3166-3, *Code for formerly used country names*. 89 *http://www.din.de/gremien/nas/nabd/iso3166ma/info_pt3.html*. 90 91 [4] United Nations, Statistics Division. 92 *http://www.un.org/Depts/unsd/statdiv.htm*. 93 94 [5] *Country or area codes in alphabetical order*. 95 *http://www.un.org/Depts/unsd/methods/m49alpha.htm*, 26 August 1999. 96 97 [6] *Codes added or changed*. 98 *http://www.un.org/Depts/unsd/methods/m49chang.htm*, 26 August 1999. 99 100 [7] *Geographical regions*. 101 *http://www.un.org/Depts/unsd/methods/m49regin.htm*, 26 August 1999. 102 103BUGS 104 Looking up information using country names is far from perfect. Except 105 for case and the amount of white space, the exact name as it appears on 106 the list has to be given. *USA* will not return anything, but *United 107 States* will. 108 109DEVELOPMENT 110 The current sources of this module are found on github, 111 <git://github.com/Abigail/geography--countries.git>. 112 113AUTHOR 114 Abigail <mailto:geography-countries@abigail.be>. 115 116COPYRIGHT and LICENSE 117 Copyright (C) 1999, 2009 by Abigail 118 119 Permission is hereby granted, free of charge, to any person obtaining a 120 copy of this software and associated documentation files (the 121 "Software"), to deal in the Software without restriction, including 122 without limitation the rights to use, copy, modify, merge, publish, 123 distribute, sublicense, and/or sell copies of the Software, and to 124 permit persons to whom the Software is furnished to do so, subject to 125 the following conditions: 126 127 The above copyright notice and this permission notice shall be included 128 in all copies or substantial portions of the Software. 129 130 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 131 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 132 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 133 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 134 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 135 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 136 DEALINGS IN THE SOFTWARE. 137 138