eaiovnaovbqoebvqoeavibavo ISBN10.pm000064400000003452147634426670006025 0ustar00package Business::ISBN10; use strict; use base qw(Business::ISBN); use Business::ISBN qw(:all); use subs qw( _checksum INVALID_GROUP_CODE INVALID_PUBLISHER_CODE BAD_CHECKSUM GOOD_ISBN BAD_ISBN ); use vars qw( $VERSION $debug $MAX_GROUP_CODE_LENGTH %ERROR_TEXT ); use Carp qw(carp croak cluck); my $debug = 0; $VERSION = '2.06'; sub _max_length { 10 } sub _set_type { $_[0]->{type} = 'ISBN10' } sub _parse_prefix { '' } sub _set_prefix { croak "Cannot set prefix [$_[1]] on an ISBN-10" if length $_[1]; $_[0]->{prefix} = $_[1]; } sub _hyphen_positions { [ $_[0]->_group_code_length, $_[0]->_group_code_length + $_[0]->_publisher_code_length, 9 ] } sub as_isbn10 { my $self = shift; my $isbn10 = Business::ISBN->new( $self->isbn ); $isbn10->fix_checksum; return $isbn10; } sub as_isbn13 { my $self = shift; my $isbn13 = Business::ISBN->new( '978' . $self->isbn ); $isbn13->fix_checksum; return $isbn13; } #internal function. you don't get to use this one. sub _checksum { my $data = $_[0]->isbn; return unless defined $data; my @digits = split //, $data; my $sum = 0; foreach( reverse 2..10 ) { $sum += $_ * (shift @digits); } #return what the check digit should be my $checksum = (11 - ($sum % 11))%11; $checksum = 'X' if $checksum == 10; return $checksum; } 1; __END__ =head1 NAME Business::ISBN10 - work with 10 digit International Standard Book Numbers =head1 SYNOPSIS See L =head1 DESCRIPTION See L =head1 SOURCE AVAILABILITY This source is in Github: https://github.com/briandfoy/business--isbn =head1 AUTHOR brian d foy C<< >> =head1 COPYRIGHT AND LICENSE Copyright (c) 2001-2013, brian d foy, All Rights Reserved. You may redistribute this under the same terms as Perl itself. =cut ISBN.pm000064400000044147147634426670005672 0ustar00package Business::ISBN; use strict; =encoding utf8 =head1 NAME Business::ISBN - work with International Standard Book Numbers =head1 SYNOPSIS use Business::ISBN; # 10 digit ISBNs $isbn10 = Business::ISBN->new('1565922573'); $isbn10 = Business::ISBN->new('1-56592-257-3'); # 13 digit ISBNs $isbn13 = Business::ISBN->new('978-0-596-52724-2'); # convert $isbn10 = $isbn13->as_isbn10; # for the 978 prefixes $isbn13 = $isbn10->as_isbn13; # maybe you don't care what it is as long as everything works $isbn = Business::ISBN->new( $ARGV[0] ); #print the ISBN with hyphens at usual positions print $isbn->as_string; #print the ISBN with hyphens at specified positions. #this not does affect the default positions print $isbn->as_string([]); #print the group code or publisher code print $isbn->group_code; print $isbn->publisher_code; #check to see if the ISBN is valid $isbn->is_valid; #fix the ISBN checksum. BEWARE: the error might not be #in the checksum! $isbn->fix_checksum; # create an EAN13 barcode in PNG format $isbn->png_barcode; =head1 DESCRIPTION This modules handles International Standard Book Numbers, including ISBN-10 and ISBN-13. =cut # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # Boring set up stuff use subs qw( _common_format INVALID_GROUP_CODE INVALID_PUBLISHER_CODE BAD_CHECKSUM GOOD_ISBN BAD_ISBN ); use vars qw( $VERSION @ISA @EXPORT_OK %EXPORT_TAGS $debug %group_data $MAX_GROUP_CODE_LENGTH %ERROR_TEXT ); use Carp qw(carp croak cluck); use base qw(Exporter); use Business::ISBN::Data 20120719.001; # now a separate module # ugh, hack *group_data = *Business::ISBN::country_data; sub _group_data { $group_data{ $_[1] } } sub _max_group_code_length { $Business::ISBN::MAX_COUNTRY_CODE_LENGTH }; sub _max_publisher_code_length { $_[0]->_max_length - $_[0]->_prefix_length # prefix - $_[0]->_group_code_length # group - 1 # article - 1; # checksum }; sub _publisher_ranges { my $self = shift; [ @{ $self->_group_data( $self->group_code )->[1] } ]; } my $debug = 0; BEGIN { @EXPORT_OK = qw( INVALID_GROUP_CODE INVALID_PUBLISHER_CODE BAD_CHECKSUM GOOD_ISBN BAD_ISBN INVALID_PREFIX %ERROR_TEXT valid_isbn_checksum ); %EXPORT_TAGS = ( 'all' => \@EXPORT_OK, ); }; $VERSION = "2.06"; sub INVALID_PREFIX () { -4 }; sub INVALID_GROUP_CODE () { -2 }; sub INVALID_PUBLISHER_CODE () { -3 }; sub BAD_CHECKSUM () { -1 }; sub GOOD_ISBN () { 1 }; sub BAD_ISBN () { 0 }; %ERROR_TEXT = ( 0 => "Bad ISBN", 1 => "Good ISBN", -1 => "Bad ISBN checksum", -2 => "Invalid group code", -3 => "Invalid publisher code", -4 => "Invalid prefix (must be 978 or 979)", ); use Business::ISBN10; use Business::ISBN13; =head2 Function interface =over 4 =item valid_isbn_checksum( ISBN10 | ISBN13 ) This function is exportable on demand, and works for either 10 or 13 character ISBNs). use Business::ISBN qw( valid_isbn_checksum ); Returns 1 if the ISBN is a valid ISBN with the right checksum. Returns 0 if the ISBN has valid prefix and publisher codes, but an invalid checksum. Returns undef if the ISBN does not validate for any other reason. =back =cut sub valid_isbn_checksum { my $isbn = shift; my $obj = Business::ISBN->new( $isbn ); return unless defined $obj; return 1 if $obj->is_valid_checksum == GOOD_ISBN; return 0 if $obj->is_valid_checksum == BAD_CHECKSUM; return; } =head2 Object interface =over 4 =item new($isbn) The constructor accepts a scalar representing the ISBN. The string representing the ISBN may contain characters other than C<[0-9xX]>, although these will be removed in the internal representation. The resulting string must look like an ISBN - the first nine characters must be digits and the tenth character must be a digit, 'x', or 'X'. The constructor attempts to determine the group code and the publisher code. If these data cannot be determined, the constructor sets C<< $obj->error >> to something other than C. An object is still returned and it is up to the program to check C<< $obj->error >> for one of five values (which may be exported on demand). The actual values of these symbolic versions are the same as those from previous versions of this module which used literal values. Business::ISBN::INVALID_PUBLISHER_CODE Business::ISBN::INVALID_GROUP_CODE Business::ISBN::BAD_CHECKSUM Business::ISBN::GOOD_ISBN Business::ISBN::BAD_ISBN If you have one of these values and want to turn it into a string, you can use the C<%Business::ISBN::ERROR_TEXT> hash, which is exportable by asking for it explicitly in the import list. use Business::ISBN qw(%ERROR_TEXT); The string passed as the ISBN need not be a valid ISBN as long as it superficially looks like one. This allows one to use the C method. Despite the disclaimer in the discussion of that method, the author has found it extremely useful. One should check the validity of the ISBN with C rather than relying on the return value of the constructor. If all one wants to do is check the validity of an ISBN, one can skip the object-oriented interface and use the C function which is exportable on demand. If the constructor decides it cannot create an object, it returns C. It may do this if the string passed as the ISBN cannot be munged to the internal format meaning that it does not even come close to looking like an ISBN. =cut # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # sub new { my $class = shift; my $input_data = shift; my $common_data = _common_format $input_data; return unless $common_data; my $self = { input_isbn => $input_data, common_data => $common_data }; my $isbn = do { if( length( $common_data ) == 10 ) { bless $self, 'Business::ISBN10'; } elsif( length( $common_data ) == 13 ) { bless $self, 'Business::ISBN13'; } else { return BAD_ISBN; } }; $self->_init( $common_data ); $self->_parse_isbn( $common_data ); return $isbn; } =back =head2 Instance methods =over 4 =item input_isbn Returns the starting ISBN. Since you may insert hyphens or fix checksums, you might want to see the original data. =cut sub input_isbn { $_[0]->{'input_isbn'} } =item common_data Returns the starting ISBN after normalization, which removes anything that isn't a digit or a valid checksum character. =cut sub common_data { $_[0]->{'common_data'} } =item isbn Returns the current value of ISBN, even if it has an invalid checksum. This is the raw data so it doesn't have the hyphens. If you want hyphenation, try C. The C method should be the same as C. =cut sub isbn { $_[0]->{'isbn'} } =item error Return the error code for the reason the ISBN isn't valid. The return value is a key in %ERROR_TEXT. =cut sub error { $_[0]->{'valid'} } =item is_valid Return true if the ISBN is valid, meaning that it has a valid prefix (for ISBN-13), group code, and publisher code; and its checksum validates. =cut sub is_valid { $_[0]->{'valid'} eq GOOD_ISBN } =item type Returns either C or C. =cut sub type { $_[0]->{'type'} } =item prefix Returns the prefix for the ISBN. This is currently either 978 or 979 for ISBN-13. It returns the empty string (so, a defined value) for ISBN-10. =cut sub prefix { $_[0]->{'prefix'} } sub _prefix_length { length $_[0]->{'prefix'} } =item group_code Returns the group code for the ISBN. This is the numerical version, for example, '0' for the English group. The valid group codes come from C. =cut sub group_code { $_[0]->{'group_code'} } =item group Returns the group name for the ISBN. This is the string version. For instance, 'English' for the '0' group. The names come from C. =cut sub group { $_[0]->_group_data( $_[0]->group_code )->[0] } sub _group_code_length { length( defined $_[0]->{'group_code'} ? $_[0]->{'group_code'} : '' ); } =item publisher_code Returns the publisher code for the ISBN. This is the numeric version, for instance '596' for O'Reilly Media. =cut sub publisher_code { $_[0]->{'publisher_code'} } sub _publisher_code_length { length( defined $_[0]->{'publisher_code'} ? $_[0]->{'publisher_code'} : '' ); } =item article_code Returns the article code for the ISBN. This is the numeric version that uniquely identifies the item. =cut sub article_code { $_[0]->{'article_code'} } =item checksum Returns the checksum code for the ISBN. This checksum may not be valid since you can create an object an fix the checksum later with C. =cut sub checksum { $_[0]->{'checksum'} } sub _checksum_pos { length( $_[0]->isbn ) - 1 } =item is_valid_checksum Returns C for valid checksums and C otherwise. This does not guarantee that the rest of the ISBN is actually assigned to a book. =cut sub is_valid_checksum { my $self = shift; cluck "is_valid_checksum: Didn't get object!" unless ref $self; no warnings 'uninitialized'; return GOOD_ISBN if $self->checksum eq $self->_checksum; return BAD_CHECKSUM; } =item fix_checksum Checks the checksum and modifies the ISBN to set it correctly if needed. =cut sub fix_checksum { my $self = shift; my $last_char = substr($self->isbn, $self->_checksum_pos, 1); my $checksum = $self->_checksum; my $isbn = $self->isbn; substr($isbn, $self->_checksum_pos, 1) = $checksum; $self->_set_isbn( $isbn ); $self->_set_checksum( $checksum ); $self->_check_validity; return 0 if $last_char eq $checksum; return 1; } =item as_string(), as_string([]) Return the ISBN as a string. This function takes an optional anonymous array (or array reference) that specifies the placement of hyphens in the string. An empty anonymous array produces a string with no hyphens. An empty argument list automatically hyphenates the ISBN based on the discovered group and publisher codes. An ISBN that is not valid may produce strange results. The positions specified in the passed anonymous array are only used for one method use and do not replace the values specified by the constructor. The method assumes that you know what you are doing and will attempt to use the least three positions specified. If you pass an anonymous array of several positions, the list will be sorted and the lowest three positions will be used. Positions less than 1 and greater than 12 are silently ignored. A terminating 'x' is changed to 'X'. =cut sub as_string { my $self = shift; my $array_ref = shift; #this allows one to override the positions settings from the #constructor $array_ref = $self->_hyphen_positions unless ref $array_ref eq ref []; # print STDERR Data::Dumper->Dump( [$array_ref], [qw(array_ref)] ); # print STDERR Data::Dumper->Dump( [$self], [qw(self)] ); return unless $self->is_valid eq GOOD_ISBN; my $isbn = $self->isbn; foreach my $position ( sort { $b <=> $a } @$array_ref ) { next if $position > 12 or $position < 1; substr($isbn, $position, 0) = '-'; } return $isbn; } =item as_isbn10 Returns a new ISBN object. If the object is already ISBN-10, this method clones it. If it is an ISBN-13 with the prefix 978, it returns the ISBN-10 equivalent. For all other cases it returns undef. =cut sub as_isbn10 { croak "as_isbn10() must be implemented in Business::ISBN subclass" } =item as_isbn13 Returns a new ISBN object. If the object is already ISBN-13, this method clones it. If it is an ISBN-10, it returns the ISBN-13 equivalent with the 978 prefix. =cut sub as_isbn13 { croak "as_isbn13() must be implemented in Business::ISBN subclass" } =item xisbn In scalar context, returns an anonymous array of related ISBNs using xISBN. In list context, returns a list. This feature requires C. =cut sub xisbn { my $self = shift; my $data = $self->_get_xisbn; $data =~ tr/x/X/; my @isbns = $data =~ m|(.*?)|ig; shift @isbns; wantarray ? @isbns : \@isbns; } sub _get_xisbn { my $self = shift; eval "use LWP::Simple"; if( $@ ) { carp "You need LWP::Simple to use xisbn()"; return; } my $data = LWP::Simple::get( $self->_xisbn_url ); carp "Could not fetch xISBN data" unless defined $data; return $data; } sub _xisbn_url { my $self = shift; my $isbn = $self->as_string([]); return "http://xisbn.worldcat.org/xid/isbn/$isbn"; } =item png_barcode Returns image data in PNG format for the barcode for the ISBN. This works with ISBN-10 and ISBN-13. The ISBN-10s are automaically converted to ISBN-13. This requires C. =cut sub png_barcode { my $self = shift; my $ean = $self->as_isbn13->as_string([]); eval "use GD::Barcode::EAN13"; if( $@ ) { carp "Need GD::Barcode::EAN13 to use png_barcode!"; return; } my $image = GD::Barcode::EAN13->new($ean)->plot->png; return $image; } =back =cut sub _set_isbn { $_[0]->{'isbn'} = $_[1]; } sub _set_is_valid { $_[0]->{'valid'} = $_[1]; } sub _set_prefix { croak "_set_prefix() must be implemented in Business::ISBN subclass" } sub _set_group_code { $_[0]->{'group_code'} = $_[1]; } sub _set_group_code_string { $_[0]->{'group_code_string'} = $_[1]; } sub _set_publisher_code { $_[0]->{'publisher_code'} = $_[1]; } sub _set_publisher_code_string { $_[0]->{'publisher_code_string'} = $_[1]; } sub _set_article_code { $_[0]->{'article_code'} = $_[1]; } sub _set_checksum { $_[0]->{'checksum'} = $_[1]; } sub _set_type { croak "_set_type() must be implemented in Business::ISBN subclass" } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # internal methods. you don't get to use this one. sub _common_format { #we want uppercase X's my $data = uc shift; #get rid of everything except decimal digits and X $data =~ s/[^0-9X]//g; return $1 if $data =~ m/ \A #anchor at start ( (?:\d\d\d)? \d{9}[0-9X] ) \z #anchor at end /x; return; } sub _init { my $self = shift; my $common_data = shift; my $class = ref $self =~ m/.*::(.*)/g; $self->_set_type; $self->_set_isbn( $common_data ); # we don't know if we have a valid group code yet # so let's assume that we don't $self->_set_is_valid( INVALID_GROUP_CODE ); } { my @methods = ( [ qw( prefix ), INVALID_PREFIX ], [ qw( group_code ), INVALID_GROUP_CODE ], [ qw( publisher_code ), INVALID_PUBLISHER_CODE ], [ qw( article_code ), BAD_ISBN ], [ qw( checksum ), BAD_CHECKSUM ], ); sub _parse_isbn { my $self = shift; foreach my $pair ( @methods ) { my( $method, $error_code ) = @$pair; my $parser = "_parse_$method"; my $result = $self->$parser; unless( defined $result ) { $self->_set_is_valid( $error_code ); #print STDERR "Got bad result for $method [$$self{isbn}]\n"; return; } $method = "_set_$method"; $self->$method( $result ); } $self->_set_is_valid( $self->is_valid_checksum ); return $self; } } sub _parse_group_code { my $self = shift; my $trial; # try this to see what we get my $group_code_length = 0; my $count = 1; GROUP_CODE: while( defined( $trial= substr($self->isbn, $self->_prefix_length, $count++) ) ) { if( defined $self->_group_data( $trial ) ) { return $trial; last GROUP_CODE; } # if we've past the point of finding a group # code we're pretty much stuffed. return if $count > $self->_max_group_code_length; } return; #failed if I got this far } sub _parse_publisher_code { my $self = shift; my $pairs = $self->_publisher_ranges; # get the longest possible publisher code # I'll try substrs of this to get the real one my $longest = substr( $self->isbn, $self->_prefix_length + $self->_group_code_length, $self->_max_publisher_code_length, ); #print STDERR "Trying to parse publisher: longest [$longest]\n"; while( @$pairs ) { my $lower = shift @$pairs; my $upper = shift @$pairs; my $trial = substr( $longest, 0, length $lower ); #print STDERR "Trying [$trial] with $lower <-> $upper [$$self{isbn}]\n"; # this has to be a sring comparison because there are # possibly leading 0s if( $trial ge $lower and $trial le $upper ) { #print STDERR "Returning $trial\n"; return $trial; } } return; #failed if I got this far } sub _parse_article_code { my $self = shift; my $head = $self->_prefix_length + $self->_group_code_length + $self->_publisher_code_length; my $length = length( $self->isbn ) - $head - 1; substr( $self->isbn, $head, $length ); } sub _parse_checksum { my $self = shift; substr( $self->isbn, -1, 1 ); } sub _check_validity { my $self = shift; if( $self->is_valid_checksum eq GOOD_ISBN and defined $self->group_code and defined $self->publisher_code and defined $self->prefix ) { $self->_set_is_valid( GOOD_ISBN ); return GOOD_ISBN; } else { $self->_set_is_valid( INVALID_PUBLISHER_CODE ) unless defined $self->publisher_code; $self->_set_is_valid( INVALID_GROUP_CODE ) unless defined $self->group_code; $self->_set_is_valid( INVALID_PREFIX ) unless defined $self->prefix; return; } } sub _hyphen_positions { croak "hyphen_positions() must be implemented in Business::ISBN subclass" } 1; __END__ =head1 BUGS =head1 TO DO * i would like to create the bar codes with the price extension =head1 SOURCE AVAILABILITY This source is in Github: https://github.com/briandfoy/business--isbn =head1 AUTHOR brian d foy C<< >> =head1 COPYRIGHT AND LICENSE Copyright (c) 2001-2013, brian d foy, All Rights Reserved. You may redistribute this under the same terms as Perl itself. =head1 CREDITS Thanks to Mark W. Eichin C<< >> for suggestions and discussions on EAN support. Thanks to Andy Lester C<< >> for lots of bug fixes and testing. Ed Summers C<< >> has volunteered to help with this module. =cut ISBN/Data.pm000064400000064255147634426670006545 0ustar00package Business::ISBN::Data; use strict; use vars qw($VERSION); use Carp qw(carp); use File::Basename qw(dirname); use File::Spec::Functions qw(catfile); $VERSION = '20120719.001'; =head1 NAME Business::ISBN::Data - data pack for Business::ISBN =head1 SYNOPSIS see L =head1 DESCRIPTION You don't need to load this module yourself in most cases. C will load it when it loads. These data are generated from the F file provided by the ISBN Agency. You can retrieve this yourself at L. This file is included as part of the distribution and should be installed at F<~lib/Business/ISBN/RangeMessage.xml>. If you want to use a different F file, you can set the C environment variable to the alternate location before you load C. This way, you can use the latest (or even earlier) data without having to install something new or wait for an update to this module. If the default F or your alternate one is not available, the module falls back to data included in F. However, that data is likely to be older data. The data are in C<%Business::ISBN::country_data> (although the "country" part is historical). If you want to see where the data are from, check C<$Business::ISBN::country_data{_source}>. =head1 SOURCE AVAILABILITY This module lives in the Github repository with Business::ISBN: git://github.com/briandfoy/business--isbn.git If you have something to add, create a fork on Github and send a pull request. =head1 AUTHOR brian d foy, C<< >> Yakov Shafranovich updated the data in October 2008. Daniel Jakubik updated the data in July 2012. =head1 COPYRIGHT AND LICENSE Copyright (c) 2002-2012, brian d foy, All Rights Reserved. You may redistribute this under the same terms as Perl itself. =cut sub _default_data { ( _source => __FILE__, 0 => ['English language' => ['00' => '19', '200' => '699', '7000' => '8499', '85000' => '89999', '900000' => '949999', '9500000' => '9999999'] ], 1 => ['English language' => ['00' => '09', '100' => '399', '4000' => '5499', '55000' => '86979', '869800' => '998999', '9990000' => '9999999'] ], 10 => ['France' => ['00' => '19', '200' => '699', '7000' => '8999', '90000' => '97599', '976000' => '999999'] ], 2 => ['French language' => ['00' => '19', '200' => '349', '35000' => '39999', '400' => '699', '7000' => '8399', '84000' => '89999', '900000' => '949999', '9500000' => '9999999'] ], 3 => ['German language' => ['00' => '02', '030' => '033', '0340' => '0369', '03700' => '03999', '04' => '19', '200' => '699', '7000' => '8499', '85000' => '89999', '900000' => '949999', '9500000' => '9539999', '95400' => '96999', '9700000' => '9899999', '99000' => '99499', '99500' => '99999'] ], 4 => ['Japan' => ['00' => '19', '200' => '699', '7000' => '8499', '85000' => '89999', '900000' => '949999', '9500000' => '9999999'] ], 5 => ['Russian Federation and former USSR' => ['00' => '19', '200' => '420', '4210' => '4299', '430' => '430', '4310' => '4399', '440' => '440', '4410' => '4499', '450' => '699', '7000' => '8499', '85000' => '89999', '900000' => '909999', '91000' => '91999', '9200' => '9299', '93000' => '94999', '9500000' => '9500999', '9501' => '9799', '98000' => '98999', '9900000' => '9909999', '9910' => '9999'] ], 600 => ['Iran' => ['00' => '09', '100' => '499', '5000' => '8999', '90000' => '99999'] ], 601 => ['Kazakhstan' => ['00' => '19', '200' => '699', '7000' => '7999', '80000' => '84999', '85' => '99'] ], 602 => ['Indonesia' => ['00' => '17', '18000' => '18999', '19000' => '19999', '200' => '749', '7500' => '7999', '8000' => '9499', '95000' => '99999'] ], 603 => ['Saudi Arabia' => ['00' => '04', '05' => '49', '500' => '799', '8000' => '8999', '90000' => '99999'] ], 604 => ['Vietnam' => ['0' => '4', '50' => '89', '900' => '979', '9800' => '9999'] ], 605 => ['Turkey' => ['' => '', '01' => '09', '100' => '399', '4000' => '5999', '60000' => '89999', '90' => '99'] ], 606 => ['Romania' => ['0' => '0', '10' => '49', '500' => '799', '8000' => '9199', '92000' => '99999'] ], 607 => ['Mexico' => ['00' => '39', '400' => '749', '7500' => '9499', '95000' => '99999'] ], 608 => ['Macedonia' => ['0' => '0', '10' => '19', '200' => '449', '4500' => '6499', '65000' => '69999', '7' => '9'] ], 609 => ['Lithuania' => ['00' => '39', '400' => '799', '8000' => '9499', '95000' => '99999'] ], 611 => ['Thailand' => ['' => ''] ], 612 => ['Peru' => ['00' => '29', '300' => '399', '4000' => '4499', '45000' => '49999', '50' => '99'] ], 613 => ['Mauritius' => ['0' => '9'] ], 614 => ['Lebanon' => ['00' => '39', '400' => '799', '8000' => '9499', '95000' => '99999'] ], 615 => ['Hungary' => ['00' => '09', '100' => '499', '5000' => '7999', '80000' => '89999', '' => ''] ], 616 => ['Thailand' => ['00' => '19', '200' => '699', '7000' => '8999', '90000' => '99999'] ], 617 => ['Ukraine' => ['00' => '49', '500' => '699', '7000' => '8999', '90000' => '99999'] ], 618 => ['Greece' => ['00' => '19', '200' => '499', '5000' => '7999', '80000' => '99999'] ], 619 => ['Bulgaria' => ['00' => '14', '150' => '699', '7000' => '8999', '90000' => '99999'] ], 620 => ['Mauritius' => ['0' => '9'] ], 7 => ['China, People\'s Republic' => ['00' => '09', '100' => '499', '5000' => '7999', '80000' => '89999', '900000' => '999999'] ], 80 => ['Czech Republic and Slovakia' => ['00' => '19', '200' => '699', '7000' => '8499', '85000' => '89999', '900000' => '999999'] ], 81 => ['India' => ['00' => '19', '200' => '699', '7000' => '8499', '85000' => '89999', '900000' => '999999'] ], 82 => ['Norway' => ['00' => '19', '200' => '699', '7000' => '8999', '90000' => '98999', '990000' => '999999'] ], 83 => ['Poland' => ['00' => '19', '200' => '599', '60000' => '69999', '7000' => '8499', '85000' => '89999', '900000' => '999999'] ], 84 => ['Spain' => ['00' => '13', '140' => '149', '15000' => '19999', '200' => '699', '7000' => '8499', '85000' => '89999', '9000' => '9199', '920000' => '923999', '92400' => '92999', '930000' => '949999', '95000' => '96999', '9700' => '9999'] ], 85 => ['Brazil' => ['00' => '19', '200' => '599', '60000' => '69999', '7000' => '8499', '85000' => '89999', '900000' => '979999', '98000' => '99999'] ], 86 => ['Serbia (shared)' => ['00' => '29', '300' => '599', '6000' => '7999', '80000' => '89999', '900000' => '999999'] ], 87 => ['Denmark' => ['00' => '29', '' => '', '400' => '649', '' => '', '7000' => '7999', '' => '', '85000' => '94999', '' => '', '970000' => '999999'] ], 88 => ['Italy' => ['00' => '19', '200' => '599', '6000' => '8499', '85000' => '89999', '900000' => '909999', '910' => '929', '' => '', '95000' => '99999'] ], 89 => ['Korea, Republic' => ['00' => '24', '250' => '549', '5500' => '8499', '85000' => '94999', '950000' => '969999', '97000' => '98999', '990' => '999'] ], 90 => ['Netherlands' => ['00' => '19', '200' => '499', '5000' => '6999', '70000' => '79999', '800000' => '849999', '8500' => '8999', '90' => '90', '910000' => '939999', '94' => '94', '950000' => '999999'] ], 91 => ['Sweden' => ['0' => '1', '20' => '49', '500' => '649', '' => '', '7000' => '7999', '' => '', '85000' => '94999', '' => '', '970000' => '999999'] ], 92 => ['International NGO Publishers and EC Organizations' => ['0' => '5', '60' => '79', '800' => '899', '9000' => '9499', '95000' => '98999', '990000' => '999999'] ], 93 => ['India' => ['00' => '09', '100' => '499', '5000' => '7999', '80000' => '94999', '950000' => '999999'] ], 94 => ['Netherlands' => ['000' => '599', '6000' => '8999', '90000' => '99999'] ], 950 => ['Argentina' => ['00' => '49', '500' => '899', '9000' => '9899', '99000' => '99999'] ], 951 => ['Finland' => ['0' => '1', '20' => '54', '550' => '889', '8900' => '9499', '95000' => '99999'] ], 952 => ['Finland' => ['00' => '19', '200' => '499', '5000' => '5999', '60' => '65', '6600' => '6699', '67000' => '69999', '7000' => '7999', '80' => '94', '9500' => '9899', '99000' => '99999'] ], 953 => ['Croatia' => ['0' => '0', '10' => '14', '150' => '509', '51' => '54', '55000' => '59999', '6000' => '9499', '95000' => '99999'] ], 954 => ['Bulgaria' => ['00' => '28', '2900' => '2999', '300' => '799', '8000' => '8999', '90000' => '92999', '9300' => '9999'] ], 955 => ['Sri Lanka' => ['0000' => '1999', '20' => '44', '4500' => '4999', '50000' => '54999', '550' => '799', '8000' => '9499', '95000' => '99999'] ], 956 => ['Chile' => ['00' => '19', '200' => '699', '7000' => '9999'] ], 957 => ['Taiwan' => ['00' => '02', '0300' => '0499', '05' => '19', '2000' => '2099', '21' => '27', '28000' => '30999', '31' => '43', '440' => '819', '8200' => '9699', '97000' => '99999'] ], 958 => ['Colombia' => ['00' => '56', '57000' => '59999', '600' => '799', '8000' => '9499', '95000' => '99999'] ], 959 => ['Cuba' => ['00' => '19', '200' => '699', '7000' => '8499', '85000' => '99999'] ], 960 => ['Greece' => ['00' => '19', '200' => '659', '6600' => '6899', '690' => '699', '7000' => '8499', '85000' => '92999', '93' => '93', '9400' => '9799', '98000' => '99999'] ], 961 => ['Slovenia' => ['00' => '19', '200' => '599', '6000' => '8999', '90000' => '94999', '' => ''] ], 962 => ['Hong Kong, China' => ['00' => '19', '200' => '699', '7000' => '8499', '85000' => '86999', '8700' => '8999', '900' => '999'] ], 963 => ['Hungary' => ['00' => '19', '200' => '699', '7000' => '8499', '85000' => '89999', '9000' => '9999'] ], 964 => ['Iran' => ['00' => '14', '150' => '249', '2500' => '2999', '300' => '549', '5500' => '8999', '90000' => '96999', '970' => '989', '9900' => '9999'] ], 965 => ['Israel' => ['00' => '19', '200' => '599', '' => '', '7000' => '7999', '' => '', '90000' => '99999'] ], 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'] ], 967 => ['Malaysia' => ['00' => '00', '0100' => '0999', '10000' => '19999', '' => '', '300' => '499', '5000' => '5999', '60' => '89', '900' => '989', '9900' => '9989', '99900' => '99999'] ], 968 => ['Mexico' => ['01' => '39', '400' => '499', '5000' => '7999', '800' => '899', '9000' => '9999'] ], 969 => ['Pakistan' => ['0' => '1', '20' => '39', '400' => '799', '8000' => '9999'] ], 970 => ['Mexico' => ['01' => '59', '600' => '899', '9000' => '9099', '91000' => '96999', '9700' => '9999'] ], 971 => ['Philippines' => ['000' => '015', '0160' => '0199', '02' => '02', '0300' => '0599', '06' => '09', '10' => '49', '500' => '849', '8500' => '9099', '91000' => '95999', '9600' => '9699', '97' => '98', '9900' => '9999'] ], 972 => ['Portugal' => ['0' => '1', '20' => '54', '550' => '799', '8000' => '9499', '95000' => '99999'] ], 973 => ['Romania' => ['0' => '0', '100' => '169', '1700' => '1999', '20' => '54', '550' => '759', '7600' => '8499', '85000' => '88999', '8900' => '9499', '95000' => '99999'] ], 974 => ['Thailand' => ['00' => '19', '200' => '699', '7000' => '8499', '85000' => '89999', '90000' => '94999', '9500' => '9999'] ], 975 => ['Turkey' => ['00000' => '01999', '02' => '24', '250' => '599', '6000' => '9199', '92000' => '98999', '990' => '999'] ], 976 => ['Caribbean Community' => ['0' => '3', '40' => '59', '600' => '799', '8000' => '9499', '95000' => '99999'] ], 977 => ['Egypt' => ['00' => '19', '200' => '499', '5000' => '6999', '700' => '849', '85000' => '89999', '90' => '99'] ], 978 => ['Nigeria' => ['000' => '199', '2000' => '2999', '30000' => '79999', '8000' => '8999', '900' => '999'] ], 979 => ['Indonesia' => ['000' => '099', '1000' => '1499', '15000' => '19999', '20' => '29', '3000' => '3999', '400' => '799', '8000' => '9499', '95000' => '99999'] ], 980 => ['Venezuela' => ['00' => '19', '200' => '599', '6000' => '9999'] ], 981 => ['Singapore' => ['00' => '11', '1200' => '1999', '200' => '289', '2900' => '9999'] ], 982 => ['South Pacific' => ['00' => '09', '100' => '699', '70' => '89', '9000' => '9799', '98000' => '99999'] ], 983 => ['Malaysia' => ['00' => '01', '020' => '199', '2000' => '3999', '40000' => '44999', '45' => '49', '50' => '79', '800' => '899', '9000' => '9899', '99000' => '99999'] ], 984 => ['Bangladesh' => ['00' => '39', '400' => '799', '8000' => '8999', '90000' => '99999'] ], 985 => ['Belarus' => ['00' => '39', '400' => '599', '6000' => '8999', '90000' => '99999'] ], 986 => ['Taiwan' => ['00' => '11', '120' => '559', '5600' => '7999', '80000' => '99999'] ], 987 => ['Argentina' => ['00' => '09', '1000' => '1999', '20000' => '29999', '30' => '49', '500' => '899', '9000' => '9499', '95000' => '99999'] ], 988 => ['Hong Kong, China' => ['00' => '14', '15000' => '16999', '17000' => '19999', '200' => '799', '8000' => '9699', '97000' => '99999'] ], 989 => ['Portugal' => ['0' => '1', '20' => '54', '550' => '799', '8000' => '9499', '95000' => '99999'] ], 9927 => ['Qatar' => ['00' => '09', '100' => '399', '4000' => '4999', '' => ''] ], 9928 => ['Albania' => ['00' => '09', '100' => '399', '4000' => '4999', '' => ''] ], 9929 => ['Guatemala' => ['0' => '3', '40' => '54', '550' => '799', '8000' => '9999'] ], 9930 => ['Costa Rica' => ['00' => '49', '500' => '939', '9400' => '9999'] ], 9931 => ['Algeria' => ['00' => '29', '300' => '899', '9000' => '9999'] ], 9932 => ['Lao People\'s Democratic Republic' => ['00' => '39', '400' => '849', '8500' => '9999'] ], 9933 => ['Syria' => ['0' => '0', '10' => '39', '400' => '899', '9000' => '9999'] ], 9934 => ['Latvia' => ['0' => '0', '10' => '49', '500' => '799', '8000' => '9999'] ], 9935 => ['Iceland' => ['0' => '0', '10' => '39', '400' => '899', '9000' => '9999'] ], 9936 => ['Afghanistan' => ['0' => '1', '20' => '39', '400' => '799', '8000' => '9999'] ], 9937 => ['Nepal' => ['0' => '2', '30' => '49', '500' => '799', '8000' => '9999'] ], 9938 => ['Tunisia' => ['00' => '79', '800' => '949', '9500' => '9999'] ], 9939 => ['Armenia' => ['0' => '4', '50' => '79', '800' => '899', '9000' => '9999'] ], 9940 => ['Montenegro' => ['0' => '1', '20' => '49', '500' => '899', '9000' => '9999'] ], 9941 => ['Georgia' => ['0' => '0', '10' => '39', '400' => '899', '9000' => '9999'] ], 9942 => ['Ecuador' => ['00' => '89', '900' => '984', '9850' => '9999'] ], 9943 => ['Uzbekistan' => ['00' => '29', '300' => '399', '4000' => '9999'] ], 9944 => ['Turkey' => ['0000' => '0999', '100' => '499', '5000' => '5999', '60' => '69', '700' => '799', '80' => '89', '900' => '999'] ], 9945 => ['Dominican Republic' => ['00' => '00', '010' => '079', '08' => '39', '400' => '569', '57' => '57', '580' => '849', '8500' => '9999'] ], 9946 => ['Korea, P.D.R.' => ['0' => '1', '20' => '39', '400' => '899', '9000' => '9999'] ], 9947 => ['Algeria' => ['0' => '1', '20' => '79', '800' => '999'] ], 9948 => ['United Arab Emirates' => ['00' => '39', '400' => '849', '8500' => '9999'] ], 9949 => ['Estonia' => ['0' => '0', '10' => '39', '400' => '899', '9000' => '9999'] ], 9950 => ['Palestine' => ['00' => '29', '300' => '849', '8500' => '9999'] ], 9951 => ['Kosova' => ['00' => '39', '400' => '849', '8500' => '9999'] ], 9952 => ['Azerbaijan' => ['0' => '1', '20' => '39', '400' => '799', '8000' => '9999'] ], 9953 => ['Lebanon' => ['0' => '0', '10' => '39', '400' => '599', '60' => '89', '9000' => '9999'] ], 9954 => ['Morocco' => ['0' => '1', '20' => '39', '400' => '799', '8000' => '9999'] ], 9955 => ['Lithuania' => ['00' => '39', '400' => '929', '9300' => '9999'] ], 9956 => ['Cameroon' => ['0' => '0', '10' => '39', '400' => '899', '9000' => '9999'] ], 9957 => ['Jordan' => ['00' => '39', '400' => '699', '70' => '84', '8500' => '8799', '88' => '99'] ], 9958 => ['Bosnia and Herzegovina' => ['00' => '03', '040' => '089', '0900' => '0999', '10' => '18', '1900' => '1999', '20' => '49', '500' => '899', '9000' => '9999'] ], 9959 => ['Libya' => ['0' => '1', '20' => '79', '800' => '949', '9500' => '9699', '970' => '979', '98' => '99'] ], 9960 => ['Saudi Arabia' => ['00' => '59', '600' => '899', '9000' => '9999'] ], 9961 => ['Algeria' => ['0' => '2', '30' => '69', '700' => '949', '9500' => '9999'] ], 9962 => ['Panama' => ['00' => '54', '5500' => '5599', '56' => '59', '600' => '849', '8500' => '9999'] ], 9963 => ['Cyprus' => ['0' => '1', '20' => '24', '250' => '279', '2800' => '2999', '30' => '54', '550' => '734', '7350' => '7499', '7500' => '9999'] ], 9964 => ['Ghana' => ['0' => '6', '70' => '94', '950' => '999'] ], 9965 => ['Kazakhstan' => ['00' => '39', '400' => '899', '9000' => '9999'] ], 9966 => ['Kenya' => ['000' => '149', '1500' => '1999', '20' => '69', '7000' => '7499', '750' => '959', '9600' => '9999'] ], 9967 => ['Kyrgyz Republic' => ['00' => '39', '400' => '899', '9000' => '9999'] ], 9968 => ['Costa Rica' => ['00' => '49', '500' => '939', '9400' => '9999'] ], 9970 => ['Uganda' => ['00' => '39', '400' => '899', '9000' => '9999'] ], 9971 => ['Singapore' => ['0' => '5', '60' => '89', '900' => '989', '9900' => '9999'] ], 9972 => ['Peru' => ['00' => '09', '1' => '1', '200' => '249', '2500' => '2999', '30' => '59', '600' => '899', '9000' => '9999'] ], 9973 => ['Tunisia' => ['00' => '05', '060' => '089', '0900' => '0999', '10' => '69', '700' => '969', '9700' => '9999'] ], 9974 => ['Uruguay' => ['0' => '2', '30' => '54', '550' => '749', '7500' => '9499', '95' => '99'] ], 9975 => ['Moldova' => ['0' => '0', '100' => '399', '4000' => '4499', '45' => '89', '900' => '949', '9500' => '9999'] ], 9976 => ['Tanzania' => ['0' => '5', '60' => '89', '900' => '989', '9900' => '9999'] ], 9977 => ['Costa Rica' => ['00' => '89', '900' => '989', '9900' => '9999'] ], 9978 => ['Ecuador' => ['00' => '29', '300' => '399', '40' => '94', '950' => '989', '9900' => '9999'] ], 9979 => ['Iceland' => ['0' => '4', '50' => '64', '650' => '659', '66' => '75', '760' => '899', '9000' => '9999'] ], 9980 => ['Papua New Guinea' => ['0' => '3', '40' => '89', '900' => '989', '9900' => '9999'] ], 9981 => ['Morocco' => ['00' => '09', '100' => '159', '1600' => '1999', '20' => '79', '800' => '949', '9500' => '9999'] ], 9982 => ['Zambia' => ['00' => '79', '800' => '989', '9900' => '9999'] ], 9983 => ['Gambia' => ['' => '', '80' => '94', '950' => '989', '9900' => '9999'] ], 9984 => ['Latvia' => ['00' => '49', '500' => '899', '9000' => '9999'] ], 9985 => ['Estonia' => ['0' => '4', '50' => '79', '800' => '899', '9000' => '9999'] ], 9986 => ['Lithuania' => ['00' => '39', '400' => '899', '9000' => '9399', '940' => '969', '97' => '99'] ], 9987 => ['Tanzania' => ['00' => '39', '400' => '879', '8800' => '9999'] ], 9988 => ['Ghana' => ['0' => '2', '30' => '54', '550' => '749', '7500' => '9999'] ], 9989 => ['Macedonia' => ['0' => '0', '100' => '199', '2000' => '2999', '30' => '59', '600' => '949', '9500' => '9999'] ], 99901 => ['Bahrain' => ['00' => '49', '500' => '799', '80' => '99'] ], 99902 => ['Gabon' => ['' => ''] ], 99903 => ['Mauritius' => ['0' => '1', '20' => '89', '900' => '999'] ], 99904 => ['Netherlands Antilles and Aruba' => ['0' => '5', '60' => '89', '900' => '999'] ], 99905 => ['Bolivia' => ['0' => '3', '40' => '79', '800' => '999'] ], 99906 => ['Kuwait' => ['0' => '2', '30' => '59', '600' => '699', '70' => '89', '90' => '94', '950' => '999'] ], 99908 => ['Malawi' => ['0' => '0', '10' => '89', '900' => '999'] ], 99909 => ['Malta' => ['0' => '3', '40' => '94', '950' => '999'] ], 99910 => ['Sierra Leone' => ['0' => '2', '30' => '89', '900' => '999'] ], 99911 => ['Lesotho' => ['00' => '59', '600' => '999'] ], 99912 => ['Botswana' => ['0' => '3', '400' => '599', '60' => '89', '900' => '999'] ], 99913 => ['Andorra' => ['0' => '2', '30' => '35', '' => '', '600' => '604', '' => ''] ], 99914 => ['Suriname' => ['0' => '4', '50' => '89', '900' => '999'] ], 99915 => ['Maldives' => ['0' => '4', '50' => '79', '800' => '999'] ], 99916 => ['Namibia' => ['0' => '2', '30' => '69', '700' => '999'] ], 99917 => ['Brunei Darussalam' => ['0' => '2', '30' => '89', '900' => '999'] ], 99918 => ['Faroe Islands' => ['0' => '3', '40' => '79', '800' => '999'] ], 99919 => ['Benin' => ['0' => '2', '300' => '399', '40' => '69', '70' => '70', '710' => '849', '850' => '899', '900' => '999'] ], 99920 => ['Andorra' => ['0' => '4', '50' => '89', '900' => '999'] ], 99921 => ['Qatar' => ['0' => '1', '20' => '69', '700' => '799', '8' => '8', '90' => '99'] ], 99922 => ['Guatemala' => ['0' => '3', '40' => '69', '700' => '999'] ], 99923 => ['El Salvador' => ['0' => '1', '20' => '79', '800' => '999'] ], 99924 => ['Nicaragua' => ['0' => '1', '20' => '79', '800' => '999'] ], 99925 => ['Paraguay' => ['0' => '3', '40' => '79', '800' => '999'] ], 99926 => ['Honduras' => ['0' => '0', '10' => '59', '600' => '899', '90' => '99'] ], 99927 => ['Albania' => ['0' => '2', '30' => '59', '600' => '999'] ], 99928 => ['Georgia' => ['0' => '0', '10' => '79', '800' => '999'] ], 99929 => ['Mongolia' => ['0' => '4', '50' => '79', '800' => '999'] ], 99930 => ['Armenia' => ['0' => '4', '50' => '79', '800' => '999'] ], 99931 => ['Seychelles' => ['0' => '4', '50' => '79', '800' => '999'] ], 99932 => ['Malta' => ['0' => '0', '10' => '59', '600' => '699', '7' => '7', '80' => '99'] ], 99933 => ['Nepal' => ['0' => '2', '30' => '59', '600' => '999'] ], 99934 => ['Dominican Republic' => ['0' => '1', '20' => '79', '800' => '999'] ], 99935 => ['Haiti' => ['0' => '2', '30' => '59', '600' => '699', '7' => '8', '90' => '99'] ], 99936 => ['Bhutan' => ['0' => '0', '10' => '59', '600' => '999'] ], 99937 => ['Macau' => ['0' => '1', '20' => '59', '600' => '999'] ], 99938 => ['Srpska, Republic of' => ['0' => '1', '20' => '59', '600' => '899', '90' => '99'] ], 99939 => ['Guatemala' => ['0' => '5', '60' => '89', '900' => '999'] ], 99940 => ['Georgia' => ['0' => '0', '10' => '69', '700' => '999'] ], 99941 => ['Armenia' => ['0' => '2', '30' => '79', '800' => '999'] ], 99942 => ['Sudan' => ['0' => '4', '50' => '79', '800' => '999'] ], 99943 => ['Albania' => ['0' => '2', '30' => '59', '600' => '999'] ], 99944 => ['Ethiopia' => ['0' => '4', '50' => '79', '800' => '999'] ], 99945 => ['Namibia' => ['0' => '5', '60' => '89', '900' => '999'] ], 99946 => ['Nepal' => ['0' => '2', '30' => '59', '600' => '999'] ], 99947 => ['Tajikistan' => ['0' => '2', '30' => '69', '700' => '999'] ], 99948 => ['Eritrea' => ['0' => '4', '50' => '79', '800' => '999'] ], 99949 => ['Mauritius' => ['0' => '1', '20' => '89', '900' => '999'] ], 99950 => ['Cambodia' => ['0' => '4', '50' => '79', '800' => '999'] ], 99951 => ['Congo, The Democratic Republic' => ['' => ''] ], 99952 => ['Mali' => ['0' => '4', '50' => '79', '800' => '999'] ], 99953 => ['Paraguay' => ['0' => '2', '30' => '79', '800' => '939', '94' => '99'] ], 99954 => ['Bolivia' => ['0' => '2', '30' => '69', '700' => '879', '88' => '99'] ], 99955 => ['Srpska, Republic of' => ['0' => '1', '20' => '59', '600' => '799', '80' => '89', '90' => '99'] ], 99956 => ['Albania' => ['00' => '59', '600' => '859', '86' => '99'] ], 99957 => ['Malta' => ['0' => '1', '20' => '79', '800' => '999'] ], 99958 => ['Bahrain' => ['0' => '4', '50' => '94', '950' => '999'] ], 99959 => ['Luxembourg' => ['0' => '2', '30' => '59', '600' => '999'] ], 99960 => ['Malawi' => ['0' => '0', '10' => '94', '950' => '999'] ], 99961 => ['El Salvador' => ['0' => '3', '40' => '89', '900' => '999'] ], 99962 => ['Mongolia' => ['0' => '4', '50' => '79', '800' => '999'] ], 99963 => ['Cambodia' => ['00' => '49', '500' => '999'] ], 99964 => ['Nicaragua' => ['0' => '1', '20' => '79', '800' => '999'] ], 99965 => ['Macau' => ['0' => '3', '40' => '79', '800' => '999'] ], 99966 => ['Kuwait' => ['0' => '2', '30' => '69', '700' => '799', '' => '', '' => ''] ], 99967 => ['Paraguay' => ['0' => '1', '20' => '59', '600' => '899', '' => ''] ], 99968 => ['Botswana' => ['0' => '3', '400' => '599', '60' => '89', '900' => '999'] ], 99969 => ['Oman' => ['0' => '4', '50' => '79', '800' => '999'] ], 99970 => ['Haiti' => ['0' => '4', '50' => '89', '900' => '999'] ], ); } sub _get_data { # eventually fetch this from the internet # http://www.isbn-international.org/agency?rmxml=1 my $file = do { no warnings 'uninitialized'; if( -e $ENV{ISBN_RANGE_MESSAGE} ) { $ENV{ISBN_RANGE_MESSAGE} } else { my $default = catfile( dirname( __FILE__ ), 'RangeMessage.xml' ); } }; my $hash = _parse_range_message( $file ); if( defined $hash ) { return %$hash } else { _default_data() } } sub _parse_range_message { my( $file ) = @_; open my $fh, '<:utf8', $file or do { carp "Could not open $file to get ISBN range data [$!]"; return }; my $data = do { local $/; <$fh> }; my $ds; my( $serial_number ) = $data =~ m|(.*?)|; my( $date ) = $data =~ m|(.*?)|; $ds->{'_source'} = $file; $ds->{'_serial'} = $serial_number; $ds->{'_date'} = $date; my( $registration_groups ) = $data =~ m|(.*?)|s; my @groups = $registration_groups =~ m|(.*?)|sg; foreach my $group ( @groups ) { my( $prefix ) = $group =~ m|(?:97[89]-)?([0-9]+?)|; my( $agency ) = $group =~ m|(.*?)|; my @rules = map { my( $range ) = m|(.*?)|; my( $length ) = m|(.*?)|; my( $low, $high ) = split /-/, $range, 2; ( substr($low, 0, $length), substr($high, 0, $length) ); } grep { ! m|0| } $group =~ m|(.*?)|sg; $ds->{$prefix} = [ $agency => \@rules ]; } $ds; } %Business::ISBN::country_data = _get_data(); # I cheat a little bit here. I know that that the max length is # 5, and that I know that those will start with 999xx. :) # however, if the data changes I should think about this again. $Business::ISBN::MAX_COUNTRY_CODE_LENGTH = length( ( sort { $a <=> $b } grep { ! /\A_/ } keys %Business::ISBN::country_data )[-1] ); package Business::ISBN; sub isbn_group_code_string_from_number { return if $_[0] =~ /\A_/; return $Business::ISBN::country_data{ $_[0] }[0] || ''; } sub isbn_publisher_ranges_from_group_number { return if $_[0] =~ /\A_/; return $Business::ISBN::country_data{ $_[0] }[1] || []; } sub isbn_data_source { return $Business::ISBN::country_data{ '_source' } || __FILE__ } 1; ISBN/make_data.pl000075500000002446147634426670007576 0ustar00#!/usr/bin/perl use 5.010; use strict; use warnings; use LWP::Simple; my $js_url = 'http://www.isbn-international.org/converter/ranges.js'; my $js_data = get( $js_url ); die "Could not fetch $js_url!" unless defined $js_data; $js_data =~ s|.*?// \s+ ID \s+ List: \s+||s; my @keys = qw(text ranges); my %data; while( $js_data =~ / ^gi\.area(?\d+)\.text \s* = \s* "(?.*?)" ;? [\r\n]+ ^gi\.area(\1)\.pubrange \s* = \s* "(?.*?)" ;? [\r\n]+ /gmx ) { @{ $data{ $+{group} } }{ @keys } = @+{ @keys }; } foreach my $group ( sort keys %data ) { my $empty = $data{$group}{text} =~ s/\s+-\s+no ranges fixed yet\s*//; my $text = $data{$group}{text}; $text =~ s/'/\\'/g; printf "%-5s => [%s => [", $group, qq|'$text'|; ; if( $empty ) { print "] ],\n"; next; } my @ranges = map { if( /-/ ) { map { qq|'$_'| } split /-/, $_ } else { qq|'$_'|, qq|'$_'| } } split /;/, $data{$group}{ranges}; warn "Odd number of ranges for $text!\n" if @ranges % 2; foreach my $i ( 0 .. $#ranges - 1 ) { print $ranges[$i], ( " => ", ", " )[$i % 2]; } print $ranges[-1], "] ],\n"; } # 0 => ['English', ['00' => '19', '200' => '699', '7000' => '8499', '85000' => '89999', '900000' => '949999', '9500000' => '9999999' ] ], ISBN/RangeMessage.xml000064400000372536147634426670010425 0ustar00 ]> International ISBN Agency 76285306-51ac-47ce-8721-f3b4c37da03f Wed, 18 Jul 2012 19:24:42 GMT 978 International ISBN Agency 0000000-5999999 1 6000000-6499999 3 6500000-6999999 0 7000000-7999999 1 8000000-9499999 2 9500000-9899999 3 9900000-9989999 4 9990000-9999999 5 979 International ISBN Agency 0000000-0999999 0 1000000-1099999 2 1100000-9999999 0 978-0 English language 0000000-1999999 2 2000000-6999999 3 7000000-8499999 4 8500000-8999999 5 9000000-9499999 6 9500000-9999999 7 978-1 English language 0000000-0999999 2 1000000-3999999 3 4000000-5499999 4 5500000-8697999 5 8698000-9989999 6 9990000-9999999 7 978-2 French language 0000000-1999999 2 2000000-3499999 3 3500000-3999999 5 4000000-6999999 3 7000000-8399999 4 8400000-8999999 5 9000000-9499999 6 9500000-9999999 7 978-3 German language 0000000-0299999 2 0300000-0339999 3 0340000-0369999 4 0370000-0399999 5 0400000-1999999 2 2000000-6999999 3 7000000-8499999 4 8500000-8999999 5 9000000-9499999 6 9500000-9539999 7 9540000-9699999 5 9700000-9899999 7 9900000-9949999 5 9950000-9999999 5 978-4 Japan 0000000-1999999 2 2000000-6999999 3 7000000-8499999 4 8500000-8999999 5 9000000-9499999 6 9500000-9999999 7 978-5 Russian Federation and former USSR 0000000-1999999 2 2000000-4209999 3 4210000-4299999 4 4300000-4309999 3 4310000-4399999 4 4400000-4409999 3 4410000-4499999 4 4500000-6999999 3 7000000-8499999 4 8500000-8999999 5 9000000-9099999 6 9100000-9199999 5 9200000-9299999 4 9300000-9499999 5 9500000-9500999 7 9501000-9799999 4 9800000-9899999 5 9900000-9909999 7 9910000-9999999 4 978-600 Iran 0000000-0999999 2 1000000-4999999 3 5000000-8999999 4 9000000-9999999 5 978-601 Kazakhstan 0000000-1999999 2 2000000-6999999 3 7000000-7999999 4 8000000-8499999 5 8500000-9999999 2 978-602 Indonesia 0000000-1799999 2 1800000-1899999 5 1900000-1999999 5 2000000-7499999 3 7500000-7999999 4 8000000-9499999 4 9500000-9999999 5 978-603 Saudi Arabia 0000000-0499999 2 0500000-4999999 2 5000000-7999999 3 8000000-8999999 4 9000000-9999999 5 978-604 Vietnam 0000000-4999999 1 5000000-8999999 2 9000000-9799999 3 9800000-9999999 4 978-605 Turkey 0000000-0099999 0 0100000-0999999 2 1000000-3999999 3 4000000-5999999 4 6000000-8999999 5 9000000-9999999 2 978-606 Romania 0000000-0999999 1 1000000-4999999 2 5000000-7999999 3 8000000-9199999 4 9200000-9999999 5 978-607 Mexico 0000000-3999999 2 4000000-7499999 3 7500000-9499999 4 9500000-9999999 5 978-608 Macedonia 0000000-0999999 1 1000000-1999999 2 2000000-4499999 3 4500000-6499999 4 6500000-6999999 5 7000000-9999999 1 978-609 Lithuania 0000000-3999999 2 4000000-7999999 3 8000000-9499999 4 9500000-9999999 5 978-611 Thailand 0000000-9999999 0 978-612 Peru 0000000-2999999 2 3000000-3999999 3 4000000-4499999 4 4500000-4999999 5 5000000-9999999 2 978-613 Mauritius 0000000-9999999 1 978-614 Lebanon 0000000-3999999 2 4000000-7999999 3 8000000-9499999 4 9500000-9999999 5 978-615 Hungary 0000000-0999999 2 1000000-4999999 3 5000000-7999999 4 8000000-8999999 5 9000000-9999999 0 978-616 Thailand 0000000-1999999 2 2000000-6999999 3 7000000-8999999 4 9000000-9999999 5 978-617 Ukraine 0000000-4999999 2 5000000-6999999 3 7000000-8999999 4 9000000-9999999 5 978-618 Greece 0000000-1999999 2 2000000-4999999 3 5000000-7999999 4 8000000-9999999 5 978-619 Bulgaria 0000000-1499999 2 1500000-6999999 3 7000000-8999999 4 9000000-9999999 5 978-620 Mauritius 0000000-9999999 1 978-7 China, People's Republic 0000000-0999999 2 1000000-4999999 3 5000000-7999999 4 8000000-8999999 5 9000000-9999999 6 978-80 Czech Republic and Slovakia 0000000-1999999 2 2000000-6999999 3 7000000-8499999 4 8500000-8999999 5 9000000-9999999 6 978-81 India 0000000-1999999 2 2000000-6999999 3 7000000-8499999 4 8500000-8999999 5 9000000-9999999 6 978-82 Norway 0000000-1999999 2 2000000-6999999 3 7000000-8999999 4 9000000-9899999 5 9900000-9999999 6 978-83 Poland 0000000-1999999 2 2000000-5999999 3 6000000-6999999 5 7000000-8499999 4 8500000-8999999 5 9000000-9999999 6 978-84 Spain 0000000-1399999 2 1400000-1499999 3 1500000-1999999 5 2000000-6999999 3 7000000-8499999 4 8500000-8999999 5 9000000-9199999 4 9200000-9239999 6 9240000-9299999 5 9300000-9499999 6 9500000-9699999 5 9700000-9999999 4 978-85 Brazil 0000000-1999999 2 2000000-5999999 3 6000000-6999999 5 7000000-8499999 4 8500000-8999999 5 9000000-9799999 6 9800000-9999999 5 978-86 Serbia (shared) 0000000-2999999 2 3000000-5999999 3 6000000-7999999 4 8000000-8999999 5 9000000-9999999 6 978-87 Denmark 0000000-2999999 2 3000000-3999999 0 4000000-6499999 3 6500000-6999999 0 7000000-7999999 4 8000000-8499999 0 8500000-9499999 5 9500000-9699999 0 9700000-9999999 6 978-88 Italy 0000000-1999999 2 2000000-5999999 3 6000000-8499999 4 8500000-8999999 5 9000000-9099999 6 9100000-9299999 3 9300000-9499999 0 9500000-9999999 5 978-89 Korea, Republic 0000000-2499999 2 2500000-5499999 3 5500000-8499999 4 8500000-9499999 5 9500000-9699999 6 9700000-9899999 5 9900000-9999999 3 978-90 Netherlands 0000000-1999999 2 2000000-4999999 3 5000000-6999999 4 7000000-7999999 5 8000000-8499999 6 8500000-8999999 4 9000000-9099999 2 9100000-9399999 6 9400000-9499999 2 9500000-9999999 6 978-91 Sweden 0000000-1999999 1 2000000-4999999 2 5000000-6499999 3 6500000-6999999 0 7000000-7999999 4 8000000-8499999 0 8500000-9499999 5 9500000-9699999 0 9700000-9999999 6 978-92 International NGO Publishers and EC Organizations 0000000-5999999 1 6000000-7999999 2 8000000-8999999 3 9000000-9499999 4 9500000-9899999 5 9900000-9999999 6 978-93 India 0000000-0999999 2 1000000-4999999 3 5000000-7999999 4 8000000-9499999 5 9500000-9999999 6 978-94 Netherlands 0000000-5999999 3 6000000-8999999 4 9000000-9999999 5 978-950 Argentina 0000000-4999999 2 5000000-8999999 3 9000000-9899999 4 9900000-9999999 5 978-951 Finland 0000000-1999999 1 2000000-5499999 2 5500000-8899999 3 8900000-9499999 4 9500000-9999999 5 978-952 Finland 0000000-1999999 2 2000000-4999999 3 5000000-5999999 4 6000000-6599999 2 6600000-6699999 4 6700000-6999999 5 7000000-7999999 4 8000000-9499999 2 9500000-9899999 4 9900000-9999999 5 978-953 Croatia 0000000-0999999 1 1000000-1499999 2 1500000-5099999 3 5100000-5499999 2 5500000-5999999 5 6000000-9499999 4 9500000-9999999 5 978-954 Bulgaria 0000000-2899999 2 2900000-2999999 4 3000000-7999999 3 8000000-8999999 4 9000000-9299999 5 9300000-9999999 4 978-955 Sri Lanka 0000000-1999999 4 2000000-4499999 2 4500000-4999999 4 5000000-5499999 5 5500000-7999999 3 8000000-9499999 4 9500000-9999999 5 978-956 Chile 0000000-1999999 2 2000000-6999999 3 7000000-9999999 4 978-957 Taiwan 0000000-0299999 2 0300000-0499999 4 0500000-1999999 2 2000000-2099999 4 2100000-2799999 2 2800000-3099999 5 3100000-4399999 2 4400000-8199999 3 8200000-9699999 4 9700000-9999999 5 978-958 Colombia 0000000-5699999 2 5700000-5999999 5 6000000-7999999 3 8000000-9499999 4 9500000-9999999 5 978-959 Cuba 0000000-1999999 2 2000000-6999999 3 7000000-8499999 4 8500000-9999999 5 978-960 Greece 0000000-1999999 2 2000000-6599999 3 6600000-6899999 4 6900000-6999999 3 7000000-8499999 4 8500000-9299999 5 9300000-9399999 2 9400000-9799999 4 9800000-9999999 5 978-961 Slovenia 0000000-1999999 2 2000000-5999999 3 6000000-8999999 4 9000000-9499999 5 9500000-9999999 0 978-962 Hong Kong, China 0000000-1999999 2 2000000-6999999 3 7000000-8499999 4 8500000-8699999 5 8700000-8999999 4 9000000-9999999 3 978-963 Hungary 0000000-1999999 2 2000000-6999999 3 7000000-8499999 4 8500000-8999999 5 9000000-9999999 4 978-964 Iran 0000000-1499999 2 1500000-2499999 3 2500000-2999999 4 3000000-5499999 3 5500000-8999999 4 9000000-9699999 5 9700000-9899999 3 9900000-9999999 4 978-965 Israel 0000000-1999999 2 2000000-5999999 3 6000000-6999999 0 7000000-7999999 4 8000000-8999999 0 9000000-9999999 5 978-966 Ukraine 0000000-1299999 2 1300000-1399999 3 1400000-1499999 2 1500000-1699999 4 1700000-1999999 3 2000000-2789999 4 2790000-2899999 3 2900000-2999999 4 3000000-6999999 3 7000000-8999999 4 9000000-9099999 5 9100000-9499999 3 9500000-9799999 5 9800000-9999999 3 978-967 Malaysia 0000000-0099999 2 0100000-0999999 4 1000000-1999999 5 2000000-2999999 0 3000000-4999999 3 5000000-5999999 4 6000000-8999999 2 9000000-9899999 3 9900000-9989999 4 9990000-9999999 5 978-968 Mexico 0100000-3999999 2 4000000-4999999 3 5000000-7999999 4 8000000-8999999 3 9000000-9999999 4 978-969 Pakistan 0000000-1999999 1 2000000-3999999 2 4000000-7999999 3 8000000-9999999 4 978-970 Mexico 0100000-5999999 2 6000000-8999999 3 9000000-9099999 4 9100000-9699999 5 9700000-9999999 4 978-971 Philippines 0000000-0159999 3 0160000-0199999 4 0200000-0299999 2 0300000-0599999 4 0600000-0999999 2 1000000-4999999 2 5000000-8499999 3 8500000-9099999 4 9100000-9599999 5 9600000-9699999 4 9700000-9899999 2 9900000-9999999 4 978-972 Portugal 0000000-1999999 1 2000000-5499999 2 5500000-7999999 3 8000000-9499999 4 9500000-9999999 5 978-973 Romania 0000000-0999999 1 1000000-1699999 3 1700000-1999999 4 2000000-5499999 2 5500000-7599999 3 7600000-8499999 4 8500000-8899999 5 8900000-9499999 4 9500000-9999999 5 978-974 Thailand 0000000-1999999 2 2000000-6999999 3 7000000-8499999 4 8500000-8999999 5 9000000-9499999 5 9500000-9999999 4 978-975 Turkey 0000000-0199999 5 0200000-2499999 2 2500000-5999999 3 6000000-9199999 4 9200000-9899999 5 9900000-9999999 3 978-976 Caribbean Community 0000000-3999999 1 4000000-5999999 2 6000000-7999999 3 8000000-9499999 4 9500000-9999999 5 978-977 Egypt 0000000-1999999 2 2000000-4999999 3 5000000-6999999 4 7000000-8499999 3 8500000-8999999 5 9000000-9999999 2 978-978 Nigeria 0000000-1999999 3 2000000-2999999 4 3000000-7999999 5 8000000-8999999 4 9000000-9999999 3 978-979 Indonesia 0000000-0999999 3 1000000-1499999 4 1500000-1999999 5 2000000-2999999 2 3000000-3999999 4 4000000-7999999 3 8000000-9499999 4 9500000-9999999 5 978-980 Venezuela 0000000-1999999 2 2000000-5999999 3 6000000-9999999 4 978-981 Singapore 0000000-1199999 2 1200000-1999999 4 2000000-2899999 3 2900000-9999999 4 978-982 South Pacific 0000000-0999999 2 1000000-6999999 3 7000000-8999999 2 9000000-9799999 4 9800000-9999999 5 978-983 Malaysia 0000000-0199999 2 0200000-1999999 3 2000000-3999999 4 4000000-4499999 5 4500000-4999999 2 5000000-7999999 2 8000000-8999999 3 9000000-9899999 4 9900000-9999999 5 978-984 Bangladesh 0000000-3999999 2 4000000-7999999 3 8000000-8999999 4 9000000-9999999 5 978-985 Belarus 0000000-3999999 2 4000000-5999999 3 6000000-8999999 4 9000000-9999999 5 978-986 Taiwan 0000000-1199999 2 1200000-5599999 3 5600000-7999999 4 8000000-9999999 5 978-987 Argentina 0000000-0999999 2 1000000-1999999 4 2000000-2999999 5 3000000-4999999 2 5000000-8999999 3 9000000-9499999 4 9500000-9999999 5 978-988 Hong Kong, China 0000000-1499999 2 1500000-1699999 5 1700000-1999999 5 2000000-7999999 3 8000000-9699999 4 9700000-9999999 5 978-989 Portugal 0000000-1999999 1 2000000-5499999 2 5500000-7999999 3 8000000-9499999 4 9500000-9999999 5 978-9927 Qatar 0000000-0999999 2 1000000-3999999 3 4000000-4999999 4 5000000-9999999 0 978-9928 Albania 0000000-0999999 2 1000000-3999999 3 4000000-4999999 4 5000000-9999999 0 978-9929 Guatemala 0000000-3999999 1 4000000-5499999 2 5500000-7999999 3 8000000-9999999 4 978-9930 Costa Rica 0000000-4999999 2 5000000-9399999 3 9400000-9999999 4 978-9931 Algeria 0000000-2999999 2 3000000-8999999 3 9000000-9999999 4 978-9932 Lao People's Democratic Republic 0000000-3999999 2 4000000-8499999 3 8500000-9999999 4 978-9933 Syria 0000000-0999999 1 1000000-3999999 2 4000000-8999999 3 9000000-9999999 4 978-9934 Latvia 0000000-0999999 1 1000000-4999999 2 5000000-7999999 3 8000000-9999999 4 978-9935 Iceland 0000000-0999999 1 1000000-3999999 2 4000000-8999999 3 9000000-9999999 4 978-9936 Afghanistan 0000000-1999999 1 2000000-3999999 2 4000000-7999999 3 8000000-9999999 4 978-9937 Nepal 0000000-2999999 1 3000000-4999999 2 5000000-7999999 3 8000000-9999999 4 978-9938 Tunisia 0000000-7999999 2 8000000-9499999 3 9500000-9999999 4 978-9939 Armenia 0000000-4999999 1 5000000-7999999 2 8000000-8999999 3 9000000-9999999 4 978-9940 Montenegro 0000000-1999999 1 2000000-4999999 2 5000000-8999999 3 9000000-9999999 4 978-9941 Georgia 0000000-0999999 1 1000000-3999999 2 4000000-8999999 3 9000000-9999999 4 978-9942 Ecuador 0000000-8999999 2 9000000-9849999 3 9850000-9999999 4 978-9943 Uzbekistan 0000000-2999999 2 3000000-3999999 3 4000000-9999999 4 978-9944 Turkey 0000000-0999999 4 1000000-4999999 3 5000000-5999999 4 6000000-6999999 2 7000000-7999999 3 8000000-8999999 2 9000000-9999999 3 978-9945 Dominican Republic 0000000-0099999 2 0100000-0799999 3 0800000-3999999 2 4000000-5699999 3 5700000-5799999 2 5800000-8499999 3 8500000-9999999 4 978-9946 Korea, P.D.R. 0000000-1999999 1 2000000-3999999 2 4000000-8999999 3 9000000-9999999 4 978-9947 Algeria 0000000-1999999 1 2000000-7999999 2 8000000-9999999 3 978-9948 United Arab Emirates 0000000-3999999 2 4000000-8499999 3 8500000-9999999 4 978-9949 Estonia 0000000-0999999 1 1000000-3999999 2 4000000-8999999 3 9000000-9999999 4 978-9950 Palestine 0000000-2999999 2 3000000-8499999 3 8500000-9999999 4 978-9951 Kosova 0000000-3999999 2 4000000-8499999 3 8500000-9999999 4 978-9952 Azerbaijan 0000000-1999999 1 2000000-3999999 2 4000000-7999999 3 8000000-9999999 4 978-9953 Lebanon 0000000-0999999 1 1000000-3999999 2 4000000-5999999 3 6000000-8999999 2 9000000-9999999 4 978-9954 Morocco 0000000-1999999 1 2000000-3999999 2 4000000-7999999 3 8000000-9999999 4 978-9955 Lithuania 0000000-3999999 2 4000000-9299999 3 9300000-9999999 4 978-9956 Cameroon 0000000-0999999 1 1000000-3999999 2 4000000-8999999 3 9000000-9999999 4 978-9957 Jordan 0000000-3999999 2 4000000-6999999 3 7000000-8499999 2 8500000-8799999 4 8800000-9999999 2 978-9958 Bosnia and Herzegovina 0000000-0399999 2 0400000-0899999 3 0900000-0999999 4 1000000-1899999 2 1900000-1999999 4 2000000-4999999 2 5000000-8999999 3 9000000-9999999 4 978-9959 Libya 0000000-1999999 1 2000000-7999999 2 8000000-9499999 3 9500000-9699999 4 9700000-9799999 3 9800000-9999999 2 978-9960 Saudi Arabia 0000000-5999999 2 6000000-8999999 3 9000000-9999999 4 978-9961 Algeria 0000000-2999999 1 3000000-6999999 2 7000000-9499999 3 9500000-9999999 4 978-9962 Panama 0000000-5499999 2 5500000-5599999 4 5600000-5999999 2 6000000-8499999 3 8500000-9999999 4 978-9963 Cyprus 0000000-1999999 1 2000000-2499999 2 2500000-2799999 3 2800000-2999999 4 3000000-5499999 2 5500000-7349999 3 7350000-7499999 4 7500000-9999999 4 978-9964 Ghana 0000000-6999999 1 7000000-9499999 2 9500000-9999999 3 978-9965 Kazakhstan 0000000-3999999 2 4000000-8999999 3 9000000-9999999 4 978-9966 Kenya 0000000-1499999 3 1500000-1999999 4 2000000-6999999 2 7000000-7499999 4 7500000-9599999 3 9600000-9999999 4 978-9967 Kyrgyz Republic 0000000-3999999 2 4000000-8999999 3 9000000-9999999 4 978-9968 Costa Rica 0000000-4999999 2 5000000-9399999 3 9400000-9999999 4 978-9970 Uganda 0000000-3999999 2 4000000-8999999 3 9000000-9999999 4 978-9971 Singapore 0000000-5999999 1 6000000-8999999 2 9000000-9899999 3 9900000-9999999 4 978-9972 Peru 0000000-0999999 2 1000000-1999999 1 2000000-2499999 3 2500000-2999999 4 3000000-5999999 2 6000000-8999999 3 9000000-9999999 4 978-9973 Tunisia 0000000-0599999 2 0600000-0899999 3 0900000-0999999 4 1000000-6999999 2 7000000-9699999 3 9700000-9999999 4 978-9974 Uruguay 0000000-2999999 1 3000000-5499999 2 5500000-7499999 3 7500000-9499999 4 9500000-9999999 2 978-9975 Moldova 0000000-0999999 1 1000000-3999999 3 4000000-4499999 4 4500000-8999999 2 9000000-9499999 3 9500000-9999999 4 978-9976 Tanzania 0000000-5999999 1 6000000-8999999 2 9000000-9899999 3 9900000-9999999 4 978-9977 Costa Rica 0000000-8999999 2 9000000-9899999 3 9900000-9999999 4 978-9978 Ecuador 0000000-2999999 2 3000000-3999999 3 4000000-9499999 2 9500000-9899999 3 9900000-9999999 4 978-9979 Iceland 0000000-4999999 1 5000000-6499999 2 6500000-6599999 3 6600000-7599999 2 7600000-8999999 3 9000000-9999999 4 978-9980 Papua New Guinea 0000000-3999999 1 4000000-8999999 2 9000000-9899999 3 9900000-9999999 4 978-9981 Morocco 0000000-0999999 2 1000000-1599999 3 1600000-1999999 4 2000000-7999999 2 8000000-9499999 3 9500000-9999999 4 978-9982 Zambia 0000000-7999999 2 8000000-9899999 3 9900000-9999999 4 978-9983 Gambia 0000000-7999999 0 8000000-9499999 2 9500000-9899999 3 9900000-9999999 4 978-9984 Latvia 0000000-4999999 2 5000000-8999999 3 9000000-9999999 4 978-9985 Estonia 0000000-4999999 1 5000000-7999999 2 8000000-8999999 3 9000000-9999999 4 978-9986 Lithuania 0000000-3999999 2 4000000-8999999 3 9000000-9399999 4 9400000-9699999 3 9700000-9999999 2 978-9987 Tanzania 0000000-3999999 2 4000000-8799999 3 8800000-9999999 4 978-9988 Ghana 0000000-2999999 1 3000000-5499999 2 5500000-7499999 3 7500000-9999999 4 978-9989 Macedonia 0000000-0999999 1 1000000-1999999 3 2000000-2999999 4 3000000-5999999 2 6000000-9499999 3 9500000-9999999 4 978-99901 Bahrain 0000000-4999999 2 5000000-7999999 3 8000000-9999999 2 978-99902 Gabon 0000000-9999999 0 978-99903 Mauritius 0000000-1999999 1 2000000-8999999 2 9000000-9999999 3 978-99904 Netherlands Antilles and Aruba 0000000-5999999 1 6000000-8999999 2 9000000-9999999 3 978-99905 Bolivia 0000000-3999999 1 4000000-7999999 2 8000000-9999999 3 978-99906 Kuwait 0000000-2999999 1 3000000-5999999 2 6000000-6999999 3 7000000-8999999 2 9000000-9499999 2 9500000-9999999 3 978-99908 Malawi 0000000-0999999 1 1000000-8999999 2 9000000-9999999 3 978-99909 Malta 0000000-3999999 1 4000000-9499999 2 9500000-9999999 3 978-99910 Sierra Leone 0000000-2999999 1 3000000-8999999 2 9000000-9999999 3 978-99911 Lesotho 0000000-5999999 2 6000000-9999999 3 978-99912 Botswana 0000000-3999999 1 4000000-5999999 3 6000000-8999999 2 9000000-9999999 3 978-99913 Andorra 0000000-2999999 1 3000000-3599999 2 3600000-5999999 0 6000000-6049999 3 6050000-9999999 0 978-99914 Suriname 0000000-4999999 1 5000000-8999999 2 9000000-9999999 3 978-99915 Maldives 0000000-4999999 1 5000000-7999999 2 8000000-9999999 3 978-99916 Namibia 0000000-2999999 1 3000000-6999999 2 7000000-9999999 3 978-99917 Brunei Darussalam 0000000-2999999 1 3000000-8999999 2 9000000-9999999 3 978-99918 Faroe Islands 0000000-3999999 1 4000000-7999999 2 8000000-9999999 3 978-99919 Benin 0000000-2999999 1 3000000-3999999 3 4000000-6999999 2 7000000-7099999 2 7100000-8499999 3 8500000-8999999 3 9000000-9999999 3 978-99920 Andorra 0000000-4999999 1 5000000-8999999 2 9000000-9999999 3 978-99921 Qatar 0000000-1999999 1 2000000-6999999 2 7000000-7999999 3 8000000-8999999 1 9000000-9999999 2 978-99922 Guatemala 0000000-3999999 1 4000000-6999999 2 7000000-9999999 3 978-99923 El Salvador 0000000-1999999 1 2000000-7999999 2 8000000-9999999 3 978-99924 Nicaragua 0000000-1999999 1 2000000-7999999 2 8000000-9999999 3 978-99925 Paraguay 0000000-3999999 1 4000000-7999999 2 8000000-9999999 3 978-99926 Honduras 0000000-0999999 1 1000000-5999999 2 6000000-8999999 3 9000000-9999999 2 978-99927 Albania 0000000-2999999 1 3000000-5999999 2 6000000-9999999 3 978-99928 Georgia 0000000-0999999 1 1000000-7999999 2 8000000-9999999 3 978-99929 Mongolia 0000000-4999999 1 5000000-7999999 2 8000000-9999999 3 978-99930 Armenia 0000000-4999999 1 5000000-7999999 2 8000000-9999999 3 978-99931 Seychelles 0000000-4999999 1 5000000-7999999 2 8000000-9999999 3 978-99932 Malta 0000000-0999999 1 1000000-5999999 2 6000000-6999999 3 7000000-7999999 1 8000000-9999999 2 978-99933 Nepal 0000000-2999999 1 3000000-5999999 2 6000000-9999999 3 978-99934 Dominican Republic 0000000-1999999 1 2000000-7999999 2 8000000-9999999 3 978-99935 Haiti 0000000-2999999 1 3000000-5999999 2 6000000-6999999 3 7000000-8999999 1 9000000-9999999 2 978-99936 Bhutan 0000000-0999999 1 1000000-5999999 2 6000000-9999999 3 978-99937 Macau 0000000-1999999 1 2000000-5999999 2 6000000-9999999 3 978-99938 Srpska, Republic of 0000000-1999999 1 2000000-5999999 2 6000000-8999999 3 9000000-9999999 2 978-99939 Guatemala 0000000-5999999 1 6000000-8999999 2 9000000-9999999 3 978-99940 Georgia 0000000-0999999 1 1000000-6999999 2 7000000-9999999 3 978-99941 Armenia 0000000-2999999 1 3000000-7999999 2 8000000-9999999 3 978-99942 Sudan 0000000-4999999 1 5000000-7999999 2 8000000-9999999 3 978-99943 Albania 0000000-2999999 1 3000000-5999999 2 6000000-9999999 3 978-99944 Ethiopia 0000000-4999999 1 5000000-7999999 2 8000000-9999999 3 978-99945 Namibia 0000000-5999999 1 6000000-8999999 2 9000000-9999999 3 978-99946 Nepal 0000000-2999999 1 3000000-5999999 2 6000000-9999999 3 978-99947 Tajikistan 0000000-2999999 1 3000000-6999999 2 7000000-9999999 3 978-99948 Eritrea 0000000-4999999 1 5000000-7999999 2 8000000-9999999 3 978-99949 Mauritius 0000000-1999999 1 2000000-8999999 2 9000000-9999999 3 978-99950 Cambodia 0000000-4999999 1 5000000-7999999 2 8000000-9999999 3 978-99951 Congo, The Democratic Republic 0000000-9999999 0 978-99952 Mali 0000000-4999999 1 5000000-7999999 2 8000000-9999999 3 978-99953 Paraguay 0000000-2999999 1 3000000-7999999 2 8000000-9399999 3 9400000-9999999 2 978-99954 Bolivia 0000000-2999999 1 3000000-6999999 2 7000000-8799999 3 8800000-9999999 2 978-99955 Srpska, Republic of 0000000-1999999 1 2000000-5999999 2 6000000-7999999 3 8000000-8999999 2 9000000-9999999 2 978-99956 Albania 0000000-5999999 2 6000000-8599999 3 8600000-9999999 2 978-99957 Malta 0000000-1999999 1 2000000-7999999 2 8000000-9999999 3 978-99958 Bahrain 0000000-4999999 1 5000000-9499999 2 9500000-9999999 3 978-99959 Luxembourg 0000000-2999999 1 3000000-5999999 2 6000000-9999999 3 978-99960 Malawi 0000000-0999999 1 1000000-9499999 2 9500000-9999999 3 978-99961 El Salvador 0000000-3999999 1 4000000-8999999 2 9000000-9999999 3 978-99962 Mongolia 0000000-4999999 1 5000000-7999999 2 8000000-9999999 3 978-99963 Cambodia 0000000-4999999 2 5000000-9999999 3 978-99964 Nicaragua 0000000-1999999 1 2000000-7999999 2 8000000-9999999 3 978-99965 Macau 0000000-3999999 1 4000000-7999999 2 8000000-9999999 3 978-99966 Kuwait 0000000-2999999 1 3000000-6999999 2 7000000-7999999 3 8000000-8999999 0 9000000-9999999 0 978-99967 Paraguay 0000000-1999999 1 2000000-5999999 2 6000000-8999999 3 9000000-9999999 0 978-99968 Botswana 0000000-3999999 1 4000000-5999999 3 6000000-8999999 2 9000000-9999999 3 978-99969 Oman 0000000-4999999 1 5000000-7999999 2 8000000-9999999 3 978-99970 Haiti 0000000-4999999 1 5000000-8999999 2 9000000-9999999 3 979-10 France 0000000-1999999 2 2000000-6999999 3 7000000-8999999 4 9000000-9759999 5 9760000-9999999 6 ISBN13.pm000064400000004402147634426670006024 0ustar00package Business::ISBN13; use strict; use base qw(Business::ISBN); use Business::ISBN qw(:all); use Data::Dumper; use subs qw( _checksum INVALID_COUNTRY_CODE INVALID_PUBLISHER_CODE BAD_CHECKSUM GOOD_ISBN BAD_ISBN ); use vars qw( $VERSION $debug ); use Carp qw(carp croak cluck); my $debug = 0; $VERSION = '2.06'; sub _max_length { 13 } sub _set_type { $_[0]->{type} = 'ISBN13' } sub _parse_prefix { my $isbn = $_[0]->isbn; # stupid workaround for 'Can't modify non-lvalue subroutine call' ( $isbn =~ /\A(97[89])(.{10})\z/g )[0]; } sub _set_prefix { croak "Cannot set prefix [$_[1]] on an ISBN-13" unless $_[1] =~ m/\A97[89]\z/; $_[0]->{prefix} = $_[1]; } sub _hyphen_positions { [ $_[0]->_prefix_length, $_[0]->_prefix_length + $_[0]->_group_code_length, $_[0]->_prefix_length + $_[0]->_group_code_length + $_[0]->_publisher_code_length, $_[0]->_checksum_pos, ] } # sub group { 'Bookland' } sub as_isbn10 { my $self = shift; return unless $self->prefix eq '978'; my $isbn10 = Business::ISBN->new( substr( $self->isbn, 3 ) ); $isbn10->fix_checksum; return $isbn10; } sub as_isbn13 { my $self = shift; my $isbn13 = Business::ISBN->new( $self->as_string ); $isbn13->fix_checksum; return $isbn13; } #internal function. you don't get to use this one. sub _checksum { my $data = $_[0]->isbn; return unless defined $data; my @digits = split //, $data; my $sum = 0; foreach my $index ( 0, 2, 4, 6, 8, 10 ) { $sum += substr($data, $index, 1); $sum += 3 * substr($data, $index + 1, 1); } #take the next higher multiple of 10 and subtract the sum. #if $sum is 37, the next highest multiple of ten is 40. the #check digit would be 40 - 37 => 3. my $checksum = ( 10 * ( int( $sum / 10 ) + 1 ) - $sum ) % 10; return $checksum; } 1; __END__ =head1 NAME Business::ISBN13 - work with 13 digit International Standard Book Numbers =head1 SYNOPSIS See L =head1 DESCRIPTION See L =head1 SOURCE AVAILABILITY This source is in Github. https://github.com/briandfoy/business--isbn =head1 AUTHOR brian d foy C<< >> =head1 COPYRIGHT AND LICENSE Copyright (c) 2001-2013, brian d foy, All Rights Reserved. You may redistribute this under the same terms as Perl itself. =cut