Debian Codegraph @

lib/Business/ISBN/Data.pm

raw
1 use utf8;
2 use 5.008;
3
4 package Business::ISBN::Data;
5 use strict;
6
7 use Carp qw(carp);
8 use File::Basename qw(dirname);
9 use File::Spec::Functions qw(catfile);
10
11 our $VERSION = '20260910.001';
12
13 =encoding utf8
14
15 =head1 NAME
16
17 Business::ISBN::Data - data pack for Business::ISBN
18
19 =head1 SYNOPSIS
20
21 see L<Business::ISBN>
22
23 =head1 DESCRIPTION
24
25 You don't need to load this module yourself in most cases. L<Business::ISBN>
26 will load it when it loads. You must use L<Business::ISBN> 3.005 or later
27 because the data structure changed slightly to fix a bug with ISBN13
28 prefixes.
29
30 These data are generated from the F<RangeMessage.xml> file provided by
31 the ISBN Agency. The distributed version matches the date in the version
32 for this module. You can retrieve this yourself at L<https://www.isbn-international.org/range_file_generation>.
33 This file is included as part of the distribution and should be installed
34 at F<~lib/Business/ISBN/Data/RangeMessage.xml>.
35
36 If you want to use a different F<RangeMessage.xml> file, you can set
37 the C<ISBN_RANGE_MESSAGE> environment variable to the alternate location
38 before you load C<Business::ISBN>. This way, you can use the latest (or
39 even earlier) data without having to install something new or wait for
40 an update to this module.
41
42 If the default F<RangeMessage.xml> or your alternate one is not available,
43 the module falls back to data included in F<Data.pm>. However, that data
44 are likely to be older. If it does not find that file, it looks
45 for F<RangeMessage.xml> in the current directory.
46
47 The data are in C<%Business::ISBN::country_data> (although the "country"
48 part is historical). If you want to see where the data are from, check
49 C<$Business::ISBN::country_data{_source}>.
50
51 =head2 Packaging this module
52
53 The included F<RangeMessage.xml> is in under F<lib/> at the same level
54 as F<Data.pm>. The same data exist as the default data in the code, so
55 you don't need to pass along the distributed F<RangeMessage.xml>.
56 However, you can include a newer F<RangeMessage.xml>.
57
58 With PAR, you can add extra files to the archive with C<-a>. Put the
59 new file somewhere the module will find it (or use C<ISBN_RANGE_MESSAGE>
60 to lead it there):
61
62 pp ... -a '..../RangeMessage.xml;RangeMessage.xml'
63
64 If you put the F<RangeMessage.xml> in the current working directory of
65 the application, the module should find it.
66
67 =head2 Updating the default data
68
69 In the repo, find the F<examples/make_default_data.pl> program. Run
70 that against the latest F<RangeMessage.xml>:
71
72 % perl -Ilib examples/make_default_data.pl RangeMessage.xml
73
74 That produces the code you need to replace in the module. Check that
75 that data aren't weird: sometimes the group names have errors or
76 oddities. The program handles escaping single quotes and trimming
77 white space.
78
79 =head1 SOURCE AVAILABILITY
80
81 This module lives in a Github repository:
82
83 https://github.com/briandfoy/business-isbn-data
84
85 You are probably also interested in the module that uses it:
86
87 https://github.com/briandfoy/business-isbn
88
89 If you have something to add, create a fork on Github and send a
90 pull request.
91
92 =head1 AUTHOR
93
94 brian d foy, C<< <[email protected]> >>
95
96 Yakov Shafranovich updated the data in October 2008.
97
98 Daniel Jakubik updated the data in July 2012.
99
100 Markus Spann suggested looking for F<RangeMessage.xml> in the current
101 directory to make it work with Perl app bundlers.
102
103 Josef Moravec C<< <[email protected]> >> updated the data in January 2019.
104
105 Peter Williams fixed a serious issue with ISBN-13 (GitHub #5). You must
106 use Business::ISBN 3.005 or later because the data structure changed.
107
108 =head1 COPYRIGHT AND LICENSE
109
110 Copyright © 2002-2026, brian d foy <[email protected]>. All rights reserved.
111
112 You may redistribute this under the terms of the Artistic License 2.0.
113
114 =cut
115
116 sub _default_data {
117 # BEGIN REPLACE
118 (
119 _data_date => 'Thu, 10 Sep 2026 09:22:32 BST',
120 _serial => '9bd90878-c627-47f0-8d9a-432d469adfe9',
121 _source => __FILE__,
122 978 => {
123 0 => [ 'English language' => [ '00', '19', '200', '227', '2280', '2289', '229', '368', '3690', '3699', '370', '638', '6390', '6397', '6398000', '6399999', '640', '644', '6450000', '6459999', '646', '647', '6480000', '6489999', '649', '654', '6550', '6559', '656', '699', '7000', '8499', '85000', '89999', '900000', '900370', '9003710', '9003719', '900372', '949999', '9500000', '9999999' ] ],
124 1 => [ 'English language' => [ '000', '009', '01', '02', '030', '034', '0350', '0399', '040', '045', '0460', '0469', '047', '047', '0480', '0499', '05', '05', '0658000', '0699999', '0700', '0999', '100', '397', '3980', '5499', '55000', '64999', '6500', '6799', '68000', '68599', '6860', '7139', '714', '716', '7170', '7319', '7320000', '7399999', '74000', '76199', '7620', '7634', '7635000', '7649999', '76500', '77499', '7750000', '7753999', '77540', '77639', '7764000', '7764999', '77650', '77699', '7770000', '7782999', '77830', '78999', '7900', '7999', '80000', '80049', '80050', '80499', '80500', '83799', '8380000', '8384999', '83850', '86719', '8672', '8675', '86760', '86979', '869800', '915999', '9160000', '9165059', '916506', '916869', '9168700', '9169079', '916908', '919163', '9191640', '9195649', '919565', '919599', '9196000', '9196549', '919655', '972999', '9730', '9877', '987800', '991149', '9911500', '9911999', '991200', '998989', '9989900', '9999999' ] ],
125 2 => [ 'French language' => [ '00', '19', '200', '349', '35000', '39999', '400', '486', '487000', '494999', '495', '495', '4960', '4966', '49670', '49699', '497', '527', '5280', '5299', '530', '699', '7000', '8399', '84000', '89999', '900000', '919799', '91980', '91980', '919810', '919942', '9199430', '9199689', '919969', '949999', '9500000', '9999999' ] ],
126 3 => [ 'German language' => [ '00', '02', '030', '033', '0340', '0369', '03700', '03999', '04', '19', '200', '312', '3130', '3139', '314', '389', '39', '39', '400', '675', '67600', '68799', '688', '688', '68900', '69499', '6950', '8499', '85000', '89999', '900000', '949999', '9500000', '9539999', '95400', '96999', '9700000', '9849999', '98500', '99959', '9996', '9999' ] ],
127 4 => [ 'Japan' => [ '00', '19', '200', '699', '7000', '8499', '85000', '89999', '900000', '949999', '9500000', '9999999' ] ],
128 5 => [ 'former U.S.S.R' => [ '00000', '00499', '0050', '0099', '01', '19', '200', '361', '3620', '3623', '36240', '36299', '363', '420', '4210', '4299', '430', '430', '4310', '4399', '440', '440', '4410', '4499', '450', '602', '6030000', '6049999', '605', '699', '7000', '8499', '85000', '89999', '900000', '909999', '91000', '91999', '9200', '9299', '93000', '94999', '9500000', '9500999', '9501', '9799', '98000', '98999', '9900000', '9909999', '9910', '9999' ] ],
129 7 => [ 'China, People\'s Republic' => [ '00', '09', '100', '499', '5000', '7999', '80000', '89999', '900000', '999999' ] ],
130 65 => [ 'Brazil' => [ '00', '02', '250', '299', '300', '302', '5000', '6349', '80000', '81824', '82000', '89999', '900000', '902449', '975500', '999999' ] ],
131 66 => [ 'Federated Panel' => [ '30', '30' ] ],
132 80 => [ 'former Czechoslovakia' => [ '00', '19', '200', '529', '53000', '54999', '550', '689', '69000', '69999', '7000', '8499', '85000', '89999', '900000', '998999', '99900', '99999' ] ],
133 81 => [ 'India' => [ '00', '16', '17000', '17999', '180000', '189999', '19000', '19999', '200', '647', '6480', '6699', '6700', '6799', '68000', '68499', '685000', '689999', '69000', '69999', '7000', '8499', '85000', '89999', '900000', '999999' ] ],
134 82 => [ 'Norway' => [ '00', '19', '200', '689', '690000', '699999', '7000', '8999', '90000', '98999', '990000', '999999' ] ],
135 83 => [ 'Poland' => [ '00', '19', '200', '599', '60000', '69999', '7000', '8499', '85000', '89999', '900000', '999999' ] ],
136 84 => [ 'Spain' => [ '00', '09', '10000', '10499', '1050', '1199', '120000', '129999', '1300', '1399', '140', '149', '15000', '19999', '200', '699', '7000', '8499', '85000', '89999', '9000', '9199', '920000', '923999', '92400', '92999', '930000', '949999', '95000', '96999', '9700', '9999' ] ],
137 85 => [ 'Brazil' => [ '00', '19', '200', '454', '455000', '455299', '45530', '45599', '456', '528', '52900', '53199', '5320', '5339', '534', '539', '54000', '54029', '54030', '54039', '540400', '540499', '54050', '54089', '540900', '540999', '54100', '54399', '5440', '5479', '54800', '54999', '5500', '5999', '60000', '69999', '7000', '8499', '85000', '89999', '900000', '924999', '92500', '94499', '9450', '9599', '96', '97', '98000', '99999' ] ],
138 86 => [ 'former Yugoslavia' => [ '00', '29', '300', '599', '6000', '7999', '80000', '89999', '900000', '999999' ] ],
139 87 => [ 'Denmark' => [ '00', '29', '400', '649', '7000', '7999', '85000', '94999', '970000', '999999' ] ],
140 88 => [ 'Italy' => [ '00', '19', '200', '311', '31200', '31499', '315', '318', '31900', '32299', '323', '326', '3270', '3389', '339', '360', '3610', '3629', '363', '548', '5490', '5549', '555', '599', '6000', '8499', '85000', '89999', '900000', '909999', '910', '926', '9270', '9399', '940000', '947999', '94800', '99999' ] ],
141 89 => [ 'Korea, Republic' => [ '00', '24', '250', '549', '5500', '8499', '85000', '94999', '950000', '969999', '97000', '98999', '990', '999' ] ],
142 90 => [ 'Netherlands' => [ '00', '19', '200', '499', '5000', '6999', '70000', '79999', '800000', '849999', '8500', '8999', '90', '90', '94', '94' ] ],
143 91 => [ 'Sweden' => [ '0', '1', '20', '49', '500', '649', '6850', '8199', '85000', '94999', '970000', '999999' ] ],
144 92 => [ 'International NGO Publishers and EU Organizations' => [ '0', '5', '60', '79', '800', '899', '9000', '9499', '95000', '98999', '990000', '999999' ] ],
145 93 => [ 'India' => [ '00', '08', '0900', '0999', '100', '469', '47000', '47999', '48000', '49999', '5000', '7999', '80000', '95999', '960000', '999999' ] ],
146 94 => [ 'Netherlands' => [ '000', '599', '6000', '6387', '638800', '638809', '63881', '63881', '638820', '638839', '63884', '63885', '638860', '638869', '63887', '63889', '6389', '6395', '639600', '639609', '63961', '63962', '639630', '639639', '63964', '63964', '639650', '639659', '63966', '63969', '6397', '6399', '640000', '640009', '64001', '64004', '640050', '640059', '64006', '64006', '640070', '640089', '64009', '64009', '6401', '6406', '640700', '640739', '64074', '64074', '640750', '640759', '64076', '64077', '640780', '640799', '6408', '6419', '64200', '64201', '642020', '642029', '64203', '64203', '642040', '642049', '64205', '64206', '642070', '642079', '64208', '64208', '642090', '642099', '6421', '6432', '64330', '64331', '643320', '643329', '64333', '64333', '643340', '643359', '64336', '64336', '643370', '643379', '64338', '64339', '6434', '6435', '643600', '643609', '64361', '64363', '643640', '643659', '64366', '64366', '643670', '643679', '64368', '64369', '6437', '6443', '644400', '644409', '64441', '64441', '644420', '644429', '64443', '64443', '644440', '644449', '64445', '64446', '644470', '644489', '64449', '64449', '6445', '6450', '64510', '64512', '645130', '645139', '64514', '64515', '645160', '645199', '6452', '6458', '645900', '645909', '64591', '64592', '645930', '645949', '64595', '64596', '645970', '645989', '64599', '64599', '6460', '6465', '646600', '646609', '64661', '64662', '646630', '646659', '64666', '64666', '646670', '646689', '64669', '64669', '6467', '6474', '64750', '64751', '647520', '647539', '64754', '64754', '647550', '647559', '64756', '64757', '647580', '647589', '64759', '64759', '6476', '6476', '647700', '647708', '64771', '64771', '647723', '647729', '64773', '64773', '647740', '647769', '64777', '64779', '647800', '647809', '64781', '64781', '647820', '647829', '64783', '64786', '647870', '647879', '64788', '64789', '6479', '6493', '649400', '649409', '64941', '64942', '649430', '649449', '64945', '64946', '649470', '649479', '64948', '64948', '649490', '649499', '6495', '6497', '64980', '64980', '649810', '649829', '64983', '64984', '649850', '649869', '64987', '64987', '649880', '649899', '6499', '8999', '90000', '99999' ] ],
147 600 => [ 'Iran' => [ '00', '09', '100', '499', '5000', '8999', '90000', '98679', '9868', '9929', '993', '995', '99600', '99999' ] ],
148 601 => [ 'Kazakhstan' => [ '00', '19', '200', '699', '7000', '7999', '80000', '84999', '85', '99' ] ],
149 602 => [ 'Indonesia' => [ '00', '06', '0700', '1399', '14000', '14999', '1500', '1699', '17000', '19999', '200', '499', '50000', '53999', '5400', '5999', '60000', '61999', '6200', '6999', '70000', '74999', '7500', '9499', '95000', '99999' ] ],
150 603 => [ 'Saudi Arabia' => [ '00', '04', '05', '49', '500', '799', '8000', '8999', '90000', '99999' ] ],
151 604 => [ 'Vietnam' => [ '0', '2', '300', '399', '40', '46', '470', '497', '4980', '4999', '50', '89', '900', '979', '9800', '9999' ] ],
152 605 => [ 'Türkiye' => [ '00', '02', '030', '039', '04', '05', '06000', '06999', '07', '09', '100', '199', '2000', '2399', '240', '399', '4000', '5999', '60000', '74999', '7500', '7999', '80000', '89999', '9000', '9999' ] ],
153 606 => [ 'Romania' => [ '000', '099', '10', '49', '500', '799', '8000', '9099', '910', '919', '92000', '95999', '9600', '9749', '975', '999' ] ],
154 607 => [ 'Mexico' => [ '00', '25', '2600', '2649', '26500', '26999', '27', '39', '400', '588', '5890', '5929', '59300', '59999', '600', '691', '69200', '69999', '700', '749', '7500', '9499', '95000', '99999' ] ],
155 608 => [ 'North Macedonia' => [ '0', '0', '10', '19', '200', '449', '4500', '6499', '65000', '69999', '7', '9' ] ],
156 609 => [ 'Lithuania' => [ '00', '39', '400', '799', '8000', '9499', '95000', '99999' ] ],
157 611 => [ 'Thailand' => [ ] ],
158 612 => [ 'Peru' => [ '00', '29', '300', '399', '4000', '4499', '45000', '49999', '5000', '5299', '99000', '99999' ] ],
159 613 => [ 'Mauritius' => [ '0', '9' ] ],
160 614 => [ 'Lebanon' => [ '00', '39', '400', '799', '8000', '9499', '95000', '99999' ] ],
161 615 => [ 'Hungary' => [ '00', '09', '100', '499', '5000', '7999', '80000', '89999' ] ],
162 616 => [ 'Thailand' => [ '00', '19', '200', '699', '7000', '8999', '90000', '99999' ] ],
163 617 => [ 'Ukraine' => [ '00', '49', '500', '699', '7000', '8999', '9000', '9049', '90500', '99999' ] ],
164 618 => [ 'Greece' => [ '00', '19', '200', '499', '5000', '7999', '80000', '99999' ] ],
165 619 => [ 'Bulgaria' => [ '00', '14', '150', '699', '7000', '8999', '90000', '99999' ] ],
166 620 => [ 'Mauritius' => [ '0', '9' ] ],
167 621 => [ 'Philippines' => [ '00', '29', '400', '599', '8000', '8999', '95000', '99999' ] ],
168 622 => [ 'Iran' => [ '00', '10', '110', '129', '1300', '1799', '180', '182', '1830', '1899', '190', '194', '19500', '19999', '200', '459', '4600', '8749', '87500', '99999' ] ],
169 623 => [ 'Indonesia' => [ '00', '10', '110', '524', '5250', '8799', '88000', '99999' ] ],
170 624 => [ 'Sri Lanka' => [ '00', '04', '200', '249', '4850', '7199', '91000', '99999' ] ],
171 625 => [ 'Türkiye' => [ '00', '01', '320', '442', '44300', '44499', '445', '449', '5000', '7793', '77940', '77949', '7795', '8999', '90000', '99999' ] ],
172 626 => [ 'Taiwan' => [ '00', '04', '300', '499', '6500', '7999', '92500', '99999' ] ],
173 627 => [ 'Pakistan' => [ '28', '31', '500', '549', '7200', '7999', '94500', '95549' ] ],
174 628 => [ 'Colombia' => [ '00', '09', '500', '549', '7500', '8499', '95000', '99999' ] ],
175 629 => [ 'Malaysia' => [ '00', '02', '455', '499', '7100', '7999', '92000', '99999' ] ],
176 630 => [ 'Romania' => [ '300', '399', '6500', '6849', '95000', '99999' ] ],
177 631 => [ 'Argentina' => [ '00', '09', '300', '399', '6500', '7499', '90000', '99999' ] ],
178 632 => [ 'Vietnam' => [ '00', '11', '600', '679' ] ],
179 633 => [ 'Egypt' => [ '00', '01', '300', '349', '8250', '8999', '99500', '99999' ] ],
180 634 => [ 'Indonesia' => [ '00', '05', '200', '349', '7000', '7999', '96000', '99999' ] ],
181 635 => [ 'Iran' => [ '00', '04', '250', '324', '5800', '6999', '96000', '99999' ] ],
182 950 => [ 'Argentina' => [ '00', '49', '500', '899', '9000', '9899', '99000', '99999' ] ],
183 951 => [ 'Finland' => [ '0', '1', '20', '54', '550', '889', '8900', '9499', '95000', '99999' ] ],
184 952 => [ 'Finland' => [ '00', '17', '180', '189', '19500', '19999', '200', '499', '5000', '5999', '60', '64', '65000', '65999', '6600', '6699', '67000', '69999', '7000', '7999', '80', '94', '9500', '9899', '99000', '99999' ] ],
185 953 => [ 'Croatia' => [ '0', '0', '10', '14', '150', '459', '46000', '49999', '500', '500', '50100', '50999', '51', '54', '55000', '59999', '6000', '9499', '95000', '99999' ] ],
186 954 => [ 'Bulgaria' => [ '00', '28', '2900', '2999', '300', '799', '8000', '8999', '90000', '92999', '9300', '9999' ] ],
187 955 => [ 'Sri Lanka' => [ '0000', '1999', '20', '33', '3400', '3549', '35500', '35999', '3600', '3799', '38000', '38999', '3900', '4099', '41000', '44999', '4500', '4999', '50000', '54999', '550', '710', '71100', '71499', '7150', '9499', '95000', '99999' ] ],
188 956 => [ 'Chile' => [ '00', '07', '08000', '09999', '10', '19', '200', '599', '6000', '6999', '7000', '9999' ] ],
189 957 => [ 'Taiwan' => [ '00', '02', '0300', '0499', '05', '19', '2000', '2099', '21', '27', '28000', '30999', '31', '43', '440', '819', '8200', '9699', '97000', '99999' ] ],
190 958 => [ 'Colombia' => [ '00', '49', '500', '509', '5100', '5199', '52000', '53999', '5400', '5599', '56000', '59999', '600', '799', '8000', '9499', '95000', '99999' ] ],
191 959 => [ 'Cuba' => [ '00', '19', '200', '699', '7000', '8499', '85000', '99999' ] ],
192 960 => [ 'Greece' => [ '00', '19', '200', '659', '6600', '6899', '690', '699', '7000', '8499', '85000', '92999', '93', '93', '9400', '9799', '98000', '99999' ] ],
193 961 => [ 'Slovenia' => [ '00', '19', '200', '599', '6000', '8999', '90000', '97999' ] ],
194 962 => [ 'Hong Kong, China' => [ '00', '19', '200', '699', '7000', '8499', '85000', '86999', '8700', '8999', '900', '999' ] ],
195 963 => [ 'Hungary' => [ '00', '19', '200', '699', '7000', '8499', '85000', '89999', '9000', '9999' ] ],
196 964 => [ 'Iran' => [ '00', '14', '150', '249', '2500', '2999', '300', '549', '5500', '8999', '90000', '96999', '970', '989', '9900', '9999' ] ],
197 965 => [ 'Israel' => [ '00', '19', '200', '599', '7000', '7999', '90000', '99999' ] ],
198 966 => [ 'Ukraine' => [ '00', '12', '130', '139', '14', '14', '1500', '1699', '170', '199', '2000', '2789', '279', '289', '2900', '2999', '300', '699', '7000', '8999', '90000', '90999', '910', '949', '95000', '97999', '980', '999' ] ],
199 967 => [ 'Malaysia' => [ '0000', '0999', '10000', '19999', '2000', '2499', '250', '254', '25500', '26999', '2700', '2799', '2800', '2999', '300', '499', '5000', '5999', '60', '89', '900', '989', '9900', '9989', '99900', '99999' ] ],
200 968 => [ 'Mexico' => [ '01', '39', '400', '499', '5000', '7999', '800', '899', '9000', '9999' ] ],
201 969 => [ 'Pakistan' => [ '0', '1', '20', '20', '210', '219', '2200', '2299', '23000', '23999', '24', '39', '400', '749', '7500', '9999' ] ],
202 970 => [ 'Mexico' => [ '01', '59', '600', '899', '9000', '9099', '91000', '96999', '9700', '9999' ] ],
203 971 => [ 'Philippines' => [ '000', '015', '0160', '0199', '02', '02', '0300', '0599', '06', '49', '500', '849', '8500', '9099', '91000', '95999', '9600', '9699', '97', '98', '9900', '9999' ] ],
204 972 => [ 'Portugal' => [ '0', '1', '20', '54', '550', '799', '8000', '9499', '95000', '99999' ] ],
205 973 => [ 'Romania' => [ '0', '0', '100', '169', '1700', '1999', '20', '54', '550', '759', '7600', '8499', '85000', '88999', '8900', '9499', '95000', '99999' ] ],
206 974 => [ 'Thailand' => [ '00', '19', '200', '699', '7000', '8499', '85000', '89999', '90000', '94999', '9500', '9999' ] ],
207 975 => [ 'Türkiye' => [ '00000', '01999', '02', '23', '2400', '2499', '250', '599', '6000', '9199', '92000', '98999', '990', '999' ] ],
208 976 => [ 'Caribbean Community' => [ '0', '3', '40', '59', '600', '799', '8000', '9499', '95000', '99999' ] ],
209 977 => [ 'Egypt' => [ '00', '19', '200', '499', '5000', '6999', '700', '849', '85000', '87399', '8740', '8899', '890', '894', '8950', '8999', '90', '95', '9600', '9699', '970', '999' ] ],
210 978 => [ 'Nigeria' => [ '000', '199', '2000', '2999', '30000', '66999', '67', '68', '690', '699', '765', '799', '8000', '8999', '900', '999' ] ],
211 979 => [ 'Indonesia' => [ '000', '099', '1000', '1499', '15000', '19999', '20', '29', '3000', '3999', '400', '799', '8000', '9499', '95000', '99999' ] ],
212 980 => [ 'Venezuela' => [ '00', '19', '200', '599', '6000', '9999' ] ],
213 981 => [ 'Singapore' => [ '00', '16', '17000', '17999', '18', '19', '200', '299', '3000', '3099', '310', '399', '4000', '5999', '92', '99' ] ],
214 982 => [ 'South Pacific' => [ '00', '09', '100', '699', '70', '89', '9000', '9799', '98000', '99999' ] ],
215 983 => [ 'Malaysia' => [ '00', '01', '020', '199', '2000', '3999', '40000', '44999', '45', '49', '50', '79', '800', '899', '9000', '9899', '99000', '99999' ] ],
216 984 => [ 'Bangladesh' => [ '00', '21', '220', '224', '2250', '2599', '26', '28', '29000', '29999', '30', '38', '3900', '3999', '400', '799', '8000', '8999', '90000', '99999' ] ],
217 985 => [ 'Belarus' => [ '00', '39', '400', '599', '6000', '8799', '880', '899', '90000', '99999' ] ],
218 986 => [ 'Taiwan' => [ '00', '05', '06000', '06999', '0700', '0799', '08', '11', '120', '539', '5400', '7999', '80000', '99999' ] ],
219 987 => [ 'Argentina' => [ '00', '09', '1000', '1999', '20000', '29999', '30', '35', '3600', '4199', '42', '43', '4400', '4499', '45000', '48999', '4900', '4999', '500', '824', '8250', '8279', '82800', '82999', '8300', '8499', '85', '88', '8900', '9499', '95000', '99999' ] ],
220 988 => [ 'Hong Kong, China' => [ '00', '11', '12000', '19999', '200', '699', '70000', '79999', '8000', '9699', '97000', '99999' ] ],
221 989 => [ 'Portugal' => [ '0', '0', '20', '34', '35000', '36999', '37', '48', '49000', '49999', '50', '52', '53000', '54999', '550', '799', '8000', '9499', '95000', '99999' ] ],
222 9905 => [ 'Nepal' => [ '0', '0', '20', '23', '600', '624', '9900', '9999' ] ],
223 9906 => [ 'Tajikistan' => [ '20', '22', '700', '724', '9900', '9999' ] ],
224 9907 => [ 'Ecuador' => [ '0', '0', '50', '64', '800', '874', '9500', '9999' ] ],
225 9908 => [ 'Estonia' => [ '0', '3', '40', '69', '825', '899', '9700', '9999' ] ],
226 9909 => [ 'Tunisia' => [ '00', '19', '750', '849', '9800', '9999' ] ],
227 9910 => [ 'Uzbekistan' => [ '01', '18', '225', '374', '4500', '5499', '550', '799', '8000', '9999' ] ],
228 9911 => [ 'Montenegro' => [ '20', '24', '550', '749', '9500', '9999' ] ],
229 9912 => [ 'Tanzania' => [ '40', '44', '750', '799', '9700', '9999' ] ],
230 9913 => [ 'Uganda' => [ '00', '09', '600', '709', '9500', '9999' ] ],
231 9914 => [ 'Kenya' => [ '27', '55', '700', '799', '9200', '9999' ] ],
232 9915 => [ 'Uruguay' => [ '40', '59', '650', '799', '9300', '9999' ] ],
233 9916 => [ 'Estonia' => [ '0', '0', '10', '39', '4', '5', '600', '789', '79', '91', '9200', '9399', '94', '94', '9500', '9999' ] ],
234 9917 => [ 'Bolivia' => [ '0', '0', '30', '34', '600', '699', '9625', '9999' ] ],
235 9918 => [ 'Malta' => [ '0', '0', '20', '29', '600', '799', '9500', '9999' ] ],
236 9919 => [ 'Mongolia' => [ '0', '0', '20', '29', '500', '599', '9000', '9999' ] ],
237 9920 => [ 'Morocco' => [ '00', '02', '130', '199', '200', '229', '23', '42', '430', '799', '8300', '8549', '8550', '9999' ] ],
238 9921 => [ 'Kuwait' => [ '0', '0', '30', '39', '700', '899', '9700', '9999' ] ],
239 9922 => [ 'Iraq' => [ '15', '29', '500', '549', '5500', '5999', '600', '799', '8000', '9999' ] ],
240 9923 => [ 'Jordan' => [ '0', '0', '10', '69', '700', '899', '9400', '9999' ] ],
241 9924 => [ 'Cambodia' => [ '28', '39', '500', '659', '8950', '9999' ] ],
242 9925 => [ 'Cyprus' => [ '0', '2', '30', '54', '550', '734', '7350', '9999' ] ],
243 9926 => [ 'Bosnia and Herzegovina' => [ '0', '1', '20', '39', '400', '799', '8000', '9999' ] ],
244 9927 => [ 'Qatar' => [ '00', '09', '100', '399', '4000', '4999' ] ],
245 9928 => [ 'Albania' => [ '00', '09', '100', '399', '4000', '4999', '800', '899', '90', '99' ] ],
246 9929 => [ 'Guatemala' => [ '0', '3', '40', '54', '550', '799', '8000', '9799', '980', '999' ] ],
247 9930 => [ 'Costa Rica' => [ '00', '49', '500', '939', '9400', '9999' ] ],
248 9931 => [ 'Algeria' => [ '00', '23', '240', '899', '9000', '9999' ] ],
249 9932 => [ 'Lao People\'s Democratic Republic' => [ '00', '39', '400', '849', '8500', '9999' ] ],
250 9933 => [ 'Syria' => [ '0', '0', '10', '39', '400', '869', '87', '89', '9000', '9999' ] ],
251 9934 => [ 'Latvia' => [ '0', '0', '10', '49', '500', '799', '8000', '9999' ] ],
252 9935 => [ 'Iceland' => [ '0', '0', '10', '39', '400', '899', '9000', '9999' ] ],
253 9936 => [ 'Afghanistan' => [ '0', '1', '20', '39', '400', '799', '8000', '9999' ] ],
254 9937 => [ 'Nepal' => [ '0', '2', '30', '49', '500', '799', '8000', '9999' ] ],
255 9938 => [ 'Tunisia' => [ '00', '79', '800', '949', '9500', '9749', '975', '990', '9910', '9999' ] ],
256 9939 => [ 'Armenia' => [ '0', '3', '40', '47', '480', '499', '50', '79', '800', '899', '9000', '9599', '960', '979', '98', '99' ] ],
257 9940 => [ 'Montenegro' => [ '0', '1', '20', '49', '500', '839', '84', '86', '8700', '9999' ] ],
258 9941 => [ 'Georgia' => [ '0', '0', '10', '39', '400', '789', '7900', '7999', '8', '8', '9000', '9999' ] ],
259 9942 => [ 'Ecuador' => [ '00', '55', '560', '699', '7000', '7499', '750', '849', '8500', '8999', '900', '984', '9850', '9999' ] ],
260 9943 => [ 'Uzbekistan' => [ '00', '29', '300', '399', '4000', '9749', '975', '999' ] ],
261 9944 => [ 'Türkiye' => [ '0000', '0999', '100', '499', '5000', '5999', '60', '69', '700', '799', '80', '89', '900', '999' ] ],
262 9945 => [ 'Dominican Republic' => [ '00', '00', '010', '079', '08', '39', '400', '569', '57', '57', '580', '799', '80', '80', '810', '849', '8500', '9999' ] ],
263 9946 => [ 'Korea, P.D.R.' => [ '0', '1', '20', '39', '400', '899', '9000', '9999' ] ],
264 9947 => [ 'Algeria' => [ '0', '1', '20', '79', '800', '999' ] ],
265 9948 => [ 'United Arab Emirates' => [ '00', '39', '400', '519', '52', '53', '540', '609', '610', '619', '620', '849', '8500', '9949', '9950', '9974', '9975', '9999' ] ],
266 9949 => [ 'Estonia' => [ '00', '08', '090', '099', '10', '39', '400', '699', '70', '71', '7200', '7499', '75', '89', '9000', '9999' ] ],
267 9950 => [ 'Palestine' => [ '00', '29', '300', '849', '8500', '9999' ] ],
268 9951 => [ 'Kosova' => [ '00', '38', '390', '849', '8500', '9799', '980', '999' ] ],
269 9952 => [ 'Azerbaijan' => [ '0', '0', '15', '39', '400', '799', '8000', '9999' ] ],
270 9953 => [ 'Lebanon' => [ '0', '0', '10', '39', '400', '599', '60', '89', '9000', '9299', '93', '96', '970', '999' ] ],
271 9954 => [ 'Morocco' => [ '0', '1', '20', '39', '400', '799', '8000', '9899', '99', '99' ] ],
272 9955 => [ 'Lithuania' => [ '00', '39', '400', '929', '9300', '9999' ] ],
273 9956 => [ 'Cameroon' => [ '0', '0', '10', '39', '400', '899', '9000', '9999' ] ],
274 9957 => [ 'Jordan' => [ '00', '39', '400', '649', '65', '67', '680', '699', '70', '84', '8500', '8799', '88', '99' ] ],
275 9958 => [ 'Bosnia and Herzegovina' => [ '00', '01', '020', '029', '0300', '0399', '040', '089', '0900', '0999', '10', '18', '1900', '1999', '20', '49', '500', '899', '9000', '9999' ] ],
276 9959 => [ 'Libya' => [ '0', '1', '20', '79', '800', '949', '9500', '9699', '970', '979', '98', '99' ] ],
277 9960 => [ 'Saudi Arabia' => [ '00', '59', '600', '899', '9000', '9999' ] ],
278 9961 => [ 'Algeria' => [ '0', '2', '30', '69', '700', '949', '9500', '9999' ] ],
279 9962 => [ 'Panama' => [ '00', '54', '5500', '5599', '56', '59', '600', '849', '8500', '9999' ] ],
280 9963 => [ 'Cyprus' => [ '0', '1', '2000', '2499', '250', '279', '2800', '2999', '30', '54', '550', '734', '7350', '7499', '7500', '9999' ] ],
281 9964 => [ 'Ghana' => [ '0', '6', '70', '94', '950', '999' ] ],
282 9965 => [ 'Kazakhstan' => [ '00', '39', '400', '899', '9000', '9999' ] ],
283 9966 => [ 'Kenya' => [ '000', '139', '14', '14', '1500', '1999', '20', '69', '7000', '7499', '750', '820', '8210', '8249', '825', '825', '8260', '8289', '829', '959', '9600', '9999' ] ],
284 9967 => [ 'Kyrgyz Republic' => [ '00', '39', '400', '899', '9000', '9999' ] ],
285 9968 => [ 'Costa Rica' => [ '00', '49', '500', '939', '9400', '9999' ] ],
286 9969 => [ 'Algeria' => [ '00', '19', '500', '749', '9300', '9999' ] ],
287 9970 => [ 'Uganda' => [ '00', '39', '400', '899', '9000', '9999' ] ],
288 9971 => [ 'Singapore' => [ '0', '5', '60', '89', '900', '989', '9900', '9999' ] ],
289 9972 => [ 'Peru' => [ '00', '09', '1', '1', '200', '249', '2500', '2999', '30', '59', '600', '899', '9000', '9999' ] ],
290 9973 => [ 'Tunisia' => [ '00', '05', '060', '089', '0900', '0999', '10', '69', '700', '969', '9700', '9999' ] ],
291 9974 => [ 'Uruguay' => [ '0', '2', '30', '54', '550', '749', '7500', '8799', '880', '909', '91', '94', '95', '99' ] ],
292 9975 => [ 'Moldova' => [ '0', '0', '100', '299', '3000', '3999', '4000', '4499', '45', '89', '900', '949', '9500', '9999' ] ],
293 9976 => [ 'Tanzania' => [ '0', '4', '5000', '5799', '580', '589', '59', '89', '900', '989', '9900', '9999' ] ],
294 9977 => [ 'Costa Rica' => [ '00', '89', '900', '989', '9900', '9999' ] ],
295 9978 => [ 'Ecuador' => [ '00', '29', '300', '399', '40', '94', '950', '989', '9900', '9999' ] ],
296 9979 => [ 'Iceland' => [ '0', '4', '50', '64', '650', '659', '66', '75', '760', '899', '9000', '9999' ] ],
297 9980 => [ 'Papua New Guinea' => [ '0', '3', '40', '89', '900', '989', '9900', '9999' ] ],
298 9981 => [ 'Morocco' => [ '00', '09', '100', '159', '1600', '1999', '20', '79', '800', '949', '9500', '9999' ] ],
299 9982 => [ 'Zambia' => [ '00', '79', '800', '989', '9900', '9999' ] ],
300 9983 => [ 'Gambia' => [ '80', '94', '950', '989', '9900', '9999' ] ],
301 9984 => [ 'Latvia' => [ '00', '49', '500', '899', '9000', '9999' ] ],
302 9985 => [ 'Estonia' => [ '0', '4', '50', '79', '800', '899', '9000', '9999' ] ],
303 9986 => [ 'Lithuania' => [ '00', '39', '400', '899', '9000', '9399', '940', '969', '97', '99' ] ],
304 9987 => [ 'Tanzania' => [ '00', '39', '400', '879', '8800', '9999' ] ],
305 9988 => [ 'Ghana' => [ '0', '3', '40', '54', '550', '749', '7500', '9999' ] ],
306 9989 => [ 'North Macedonia' => [ '0', '0', '100', '199', '2000', '2999', '30', '59', '600', '949', '9500', '9999' ] ],
307 69990 => [ 'Zambia registration group' => [ '50', '51', '990', '999' ] ],
308 99901 => [ 'Bahrain' => [ '00', '49', '500', '799', '80', '99' ] ],
309 99902 => [ 'Reserved Agency' => [ ] ],
310 99903 => [ 'Mauritius' => [ '0', '1', '20', '89', '900', '999' ] ],
311 99904 => [ 'Curaçao' => [ '0', '5', '60', '89', '900', '999' ] ],
312 99905 => [ 'Bolivia' => [ '0', '3', '40', '79', '800', '999' ] ],
313 99906 => [ 'Kuwait' => [ '0', '2', '30', '59', '600', '699', '70', '89', '90', '94', '950', '999' ] ],
314 99908 => [ 'Malawi' => [ '0', '0', '10', '89', '900', '999' ] ],
315 99909 => [ 'Malta' => [ '0', '3', '40', '94', '950', '999' ] ],
316 99910 => [ 'Sierra Leone' => [ '0', '2', '30', '89', '900', '999' ] ],
317 99911 => [ 'Lesotho' => [ '00', '46', '470', '479', '48', '59', '600', '999' ] ],
318 99912 => [ 'Botswana' => [ '0', '3', '400', '599', '60', '89', '900', '999' ] ],
319 99913 => [ 'Andorra' => [ '0', '2', '30', '35', '600', '604' ] ],
320 99914 => [ 'International NGO Publishers' => [ '0', '4', '50', '69', '7', '7', '80', '86', '870', '879', '88', '89', '900', '999' ] ],
321 99915 => [ 'Maldives' => [ '0', '4', '50', '79', '800', '999' ] ],
322 99916 => [ 'Namibia' => [ '0', '2', '30', '69', '700', '999' ] ],
323 99917 => [ 'Brunei Darussalam' => [ '0', '2', '30', '88', '890', '999' ] ],
324 99918 => [ 'Faroe Islands' => [ '0', '3', '40', '79', '800', '999' ] ],
325 99919 => [ 'Benin' => [ '0', '2', '300', '399', '40', '79', '800', '999' ] ],
326 99920 => [ 'Andorra' => [ '0', '4', '50', '89', '900', '999' ] ],
327 99921 => [ 'Qatar' => [ '0', '1', '20', '69', '700', '799', '8', '8', '90', '99' ] ],
328 99922 => [ 'Guatemala' => [ '0', '3', '40', '69', '700', '999' ] ],
329 99923 => [ 'El Salvador' => [ '0', '1', '20', '79', '800', '999' ] ],
330 99924 => [ 'Nicaragua' => [ '0', '1', '20', '79', '800', '999' ] ],
331 99925 => [ 'Paraguay' => [ '0', '0', '10', '19', '200', '299', '3', '3', '40', '79', '800', '999' ] ],
332 99926 => [ 'Honduras' => [ '0', '0', '10', '59', '600', '869', '87', '89', '90', '99' ] ],
333 99927 => [ 'Albania' => [ '0', '2', '30', '59', '600', '999' ] ],
334 99928 => [ 'Georgia' => [ '0', '0', '10', '79', '800', '999' ] ],
335 99929 => [ 'Mongolia' => [ '0', '4', '50', '79', '800', '999' ] ],
336 99930 => [ 'Armenia' => [ '0', '4', '50', '79', '800', '999' ] ],
337 99931 => [ 'Seychelles' => [ '0', '4', '50', '79', '800', '999' ] ],
338 99932 => [ 'Malta' => [ '0', '0', '10', '59', '600', '699', '7', '7', '80', '99' ] ],
339 99933 => [ 'Nepal' => [ '0', '2', '30', '59', '600', '999' ] ],
340 99934 => [ 'Dominican Republic' => [ '0', '1', '20', '79', '800', '999' ] ],
341 99935 => [ 'Haiti' => [ '0', '2', '30', '59', '600', '699', '7', '8', '90', '99' ] ],
342 99936 => [ 'Bhutan' => [ '0', '0', '10', '59', '600', '999' ] ],
343 99937 => [ 'Macau' => [ '0', '1', '20', '59', '600', '999' ] ],
344 99938 => [ 'Srpska, Republic of' => [ '0', '1', '20', '59', '600', '899', '90', '99' ] ],
345 99939 => [ 'Guatemala' => [ '0', '2', '30', '59', '60', '89', '900', '999' ] ],
346 99940 => [ 'Georgia' => [ '0', '0', '10', '69', '700', '999' ] ],
347 99941 => [ 'Armenia' => [ '0', '2', '30', '79', '800', '999' ] ],
348 99942 => [ 'Sudan' => [ '0', '4', '50', '79', '800', '999' ] ],
349 99943 => [ 'Albania' => [ '0', '2', '30', '59', '600', '999' ] ],
350 99944 => [ 'Ethiopia' => [ '0', '4', '50', '79', '800', '999' ] ],
351 99945 => [ 'Namibia' => [ '0', '4', '50', '89', '900', '979', '98', '99' ] ],
352 99946 => [ 'Nepal' => [ '0', '2', '30', '59', '600', '999' ] ],
353 99947 => [ 'Tajikistan' => [ '0', '2', '30', '69', '700', '999' ] ],
354 99948 => [ 'Eritrea' => [ '0', '4', '50', '79', '800', '999' ] ],
355 99949 => [ 'Mauritius' => [ '0', '1', '20', '79', '8', '8', '900', '989', '99', '99' ] ],
356 99950 => [ 'Cambodia' => [ '0', '4', '50', '79', '800', '999' ] ],
357 99951 => [ 'Reserved Agency' => [ ] ],
358 99952 => [ 'Mali' => [ '0', '3', '40', '42', '430', '499', '50', '79', '800', '999' ] ],
359 99953 => [ 'Paraguay' => [ '0', '2', '30', '79', '800', '939', '94', '99' ] ],
360 99954 => [ 'Bolivia' => [ '0', '2', '30', '69', '700', '879', '88', '99' ] ],
361 99955 => [ 'Srpska, Republic of' => [ '0', '1', '20', '59', '600', '799', '80', '99' ] ],
362 99956 => [ 'Albania' => [ '00', '59', '600', '859', '86', '99' ] ],
363 99957 => [ 'Malta' => [ '0', '1', '20', '79', '800', '949', '95', '99' ] ],
364 99958 => [ 'Bahrain' => [ '0', '4', '50', '93', '940', '949', '950', '999' ] ],
365 99959 => [ 'Luxembourg' => [ '0', '2', '30', '59', '600', '999' ] ],
366 99960 => [ 'Malawi' => [ '070', '099', '10', '94', '950', '999' ] ],
367 99961 => [ 'El Salvador' => [ '0', '2', '300', '369', '37', '89', '900', '999' ] ],
368 99962 => [ 'Mongolia' => [ '0', '4', '50', '79', '800', '999' ] ],
369 99963 => [ 'Cambodia' => [ '00', '49', '500', '919', '92', '99' ] ],
370 99964 => [ 'Nicaragua' => [ '0', '1', '20', '79', '800', '999' ] ],
371 99965 => [ 'Macau' => [ '0', '2', '300', '359', '36', '62', '630', '999' ] ],
372 99966 => [ 'Kuwait' => [ '0', '2', '30', '69', '700', '799', '80', '96', '970', '999' ] ],
373 99967 => [ 'Paraguay' => [ '0', '0', '10', '59', '600', '999' ] ],
374 99968 => [ 'Botswana' => [ '0', '3', '400', '599', '60', '89', '900', '999' ] ],
375 99969 => [ 'Oman' => [ '0', '4', '50', '79', '800', '949', '95', '99' ] ],
376 99970 => [ 'Haiti' => [ '0', '4', '50', '89', '900', '999' ] ],
377 99971 => [ 'Myanmar' => [ '0', '3', '40', '84', '850', '999' ] ],
378 99972 => [ 'Faroe Islands' => [ '0', '4', '50', '89', '900', '999' ] ],
379 99973 => [ 'Mongolia' => [ '0', '3', '40', '79', '800', '999' ] ],
380 99974 => [ 'Bolivia' => [ '0', '0', '10', '25', '260', '399', '40', '63', '640', '649', '65', '79', '800', '999' ] ],
381 99975 => [ 'Tajikistan' => [ '0', '2', '300', '399', '40', '79', '800', '999' ] ],
382 99976 => [ 'Srpska, Republic of' => [ '00', '03', '040', '099', '10', '15', '160', '199', '20', '59', '600', '819', '82', '89', '900', '999' ] ],
383 99977 => [ 'Rwanda' => [ '0', '1', '40', '69', '700', '799', '900', '924', '975', '999' ] ],
384 99978 => [ 'Mongolia' => [ '0', '4', '50', '69', '700', '999' ] ],
385 99979 => [ 'Honduras' => [ '0', '3', '40', '79', '800', '999' ] ],
386 99980 => [ 'Bhutan' => [ '0', '0', '25', '64', '670', '999' ] ],
387 99981 => [ 'Macau' => [ '0', '0', '10', '10', '110', '149', '15', '19', '200', '219', '22', '74', '750', '999' ] ],
388 99982 => [ 'Benin' => [ '0', '4', '50', '79', '845', '999' ] ],
389 99983 => [ 'El Salvador' => [ '0', '0', '35', '69', '850', '999' ] ],
390 99984 => [ 'Brunei Darussalam' => [ '0', '0', '50', '69', '950', '999' ] ],
391 99985 => [ 'Tajikistan' => [ '0', '1', '200', '229', '23', '79', '800', '999' ] ],
392 99986 => [ 'Myanmar' => [ '0', '0', '50', '69', '950', '999' ] ],
393 99987 => [ 'Luxembourg' => [ '400', '999' ] ],
394 99988 => [ 'Sudan' => [ '0', '0', '10', '11', '50', '54', '800', '824' ] ],
395 99989 => [ 'Paraguay' => [ '0', '1', '45', '49', '50', '79', '875', '899', '900', '999' ] ],
396 99990 => [ 'Ethiopia' => [ '0', '1', '45', '57', '930', '999' ] ],
397 99991 => [ 'Burkina Faso' => [ '0', '0', '50', '60', '960', '999' ] ],
398 99992 => [ 'Oman' => [ '0', '2', '50', '69', '900', '999' ] ],
399 99993 => [ 'Mauritius' => [ '0', '4', '50', '54', '980', '999' ] ],
400 99994 => [ 'Haiti' => [ '0', '0', '50', '56', '960', '999' ] ],
401 99995 => [ 'Seychelles' => [ '50', '55', '975', '999' ] ],
402 99996 => [ 'Macau' => [ '0', '1', '40', '59', '900', '999' ] ],
403 99997 => [ 'Srpska, Republic of' => [ '0', '0', '40', '61', '920', '999' ] ],
404 99998 => [ 'Namibia' => [ '80', '89' ] ],
405 },
406 979 => {
407 8 => [ 'United States' => [ '030', '034', '1600', '1699', '1700', '1799', '1800', '1949', '1950', '1999', '200', '239', '2400', '2599', '2600', '2799', '2800', '2999', '3000', '8849', '88500', '89999', '90000', '90999', '94500', '94999', '950000', '969999', '9820000', '9849999', '9850000', '9929999', '9930000', '9959999', '9960000', '9984999', '9985000', '9999999' ] ],
408 10 => [ 'France' => [ '00', '19', '200', '699', '7000', '8999', '90000', '97599', '976000', '999999' ] ],
409 11 => [ 'Korea, Republic' => [ '00', '21', '220000', '229999', '23000', '24999', '250', '549', '5500', '8499', '85000', '94999', '950000', '999999' ] ],
410 12 => [ 'Italy' => [ '200', '299', '5450', '5999', '80000', '84999', '985000', '999999' ] ],
411 13 => [ 'Spain' => [ '00', '00', '600', '604', '7000', '7349', '87500', '89999', '990000', '999999' ] ],
412 },
413 );
414 # END REPLACE
415 }
416
417 sub _get_data {
418 # eventually fetch this from the internet
419 # http://www.isbn-international.org/agency?rmxml=1
420
421 if( defined $ENV{ISBN_RANGE_MESSAGE} and ! -e $ENV{ISBN_RANGE_MESSAGE} ) {
422 carp "ISBN_RANGE_MESSAGE is set to [$ENV{ISBN_RANGE_MESSAGE}] but that file does not exist!\nTrying to use the default locations\n";
423 }
424
425 my $file = 'RangeMessage.xml';
426 no warnings 'uninitialized';
427 my @candidates = grep { -e } (
428 (exists $ENV{ISBN_RANGE_MESSAGE} ? $ENV{ISBN_RANGE_MESSAGE} : ()),
429 catfile( dirname( __FILE__ ), $file ), # next to the module
430 $file, # current directory
431 );
432
433 my $hash;
434
435 $hash = _parse_range_message( $candidates[0] ) if @candidates;
436
437 if( defined $hash ) { return %$hash }
438 else { _default_data() }
439 }
440
441 sub _parse_range_message {
442 my( $file ) = @_;
443
444 open my $fh, '<:utf8', $file or do {
445 carp "Could not open $file to get ISBN range data [$!]\n";
446 return
447 };
448
449 my $data = do { local $/; <$fh> };
450
451 my $ds;
452
453 my( $serial_number ) = $data =~ m|<MessageSerialNumber>(.*?)</MessageSerialNumber>|;
454 my( $date ) = $data =~ m|<MessageDate>(.*?)</MessageDate>|;
455
456 $ds->{'_source'} = $file;
457 $ds->{'_serial'} = $serial_number;
458 $ds->{'_date'} = $date;
459
460 my( $registration_groups ) = $data =~ m|<RegistrationGroups>(.*?)</RegistrationGroups>|s;
461
462 my @groups = $registration_groups =~ m|<Group>(.*?)</Group>|sg;
463
464 foreach my $group ( @groups ) {
465 my( $isbn_prefix, $prefix ) = $group =~ m|<Prefix>(97[89]-)?([0-9]+?)</Prefix>|;
466 $isbn_prefix = $isbn_prefix eq '979-' ? "979" : "978";
467 my( $agency ) = $group =~ m|<Agency>(.*?)</Agency>|;
468 $agency =~ s/^\s+|\s+$//g; # 'Croatia ' ???
469 my @rules =
470 map {
471 my( $range ) = m|<Range>(.*?)</Range>|;
472 my( $length ) = m|<Length>(.*?)</Length>|;
473 my( $low, $high ) = split /-/, $range, 2;
474 ( substr($low, 0, $length), substr($high, 0, $length) );
475 }
476 grep {
477 ! m|<Length>0</Length>|
478 }
479 $group =~ m|<Rule>(.*?)</Rule>|sg;
480
481 $ds->{$isbn_prefix}->{$prefix} = [ $agency => \@rules ];
482 }
483
484 $ds;
485 }
486
487 %Business::ISBN::country_data = _get_data();
488
489 # I cheat a little bit here. I know that that the max length is
490 # 5, and that I know that those will start with 999xx. :)
491 # however, if the data changes I should think about this again.
492 $Business::ISBN::MAX_COUNTRY_CODE_LENGTH = length(
493 ( sort { $a <=> $b } grep { ! /\A_/ } map { keys %$_ } @Business::ISBN::country_data{qw(978 979)} )[-1]
494 );
495
496 package # Hide from PAUSE
497 Business::ISBN;
498
499 sub isbn_data_source {
500 return $Business::ISBN::country_data{ '_source' } || __FILE__
501 }
502
503 1;