Kamakshi Trivedi
Kamakshi Trivedi

Reputation: 87

Business::ISBN is not validating ISBNs with prefix 9790 in perl

Currently, I updated, Business::ISBN and Business::ISBN::Data using

cpan Business::ISBN
cpan Business::ISBN::Data

but when I tried

my $isbn = Business::ISBN->new(9790001012966);

so it gave me the following output

bless( {
             'type' => 'ISBN13',
             'prefix' => '979',
             'isbn' => '9790001012966',
             'valid' => -2,
             'input_isbn' => '9790001012966',
             'common_data' => '9790001012966'
           }, 'Business::ISBN13' );

and when I did

  print Dumper($isbn->is_valid);

it just gave a blank string

 ''

But, when I did the same steps for ISBN with the prefix 978, it gave the correct output

bless( {
             'common_data' => '9789087538460',
             'valid' => 1,
             'prefix' => '978',
             'article_code' => '846',
             'type' => 'ISBN13',
             'input_isbn' => '9789087538460',
             'checksum' => '0',
             'isbn' => '9789087538460',
             'publisher_code' => '8753',
             'group_code' => '90'
           }, 'Business::ISBN13' );

And even gave positive result when tried to validate it.

$isbn->is_valid #result is 1

What should I do now to validate ISBNs starting with the prefix 979?

Upvotes: 0

Views: 99

Answers (1)

brian d foy
brian d foy

Reputation: 132778

You don't have an ISBN. You have an EAN-13. It has the same format as an ISBN-13, but the 979-0 "group" is a special assignment for International Standard Music Numbers and is not a group assigned by the ISBN agency. Hence, it's an invalid Book number. Indeed, when you look for the "book" assigned that number, it's sheet music. That catalogs show that number as the "ISBN" data is merely sloppiness on their part.

To deal with these, take off the 9790 to get 001012966. Add M to get M001012966. That's your International Standard Music Number, which you can validate with Business::ISMN. But, Business::ISMN can do that conversion for you:

use Business::ISMN qw(ean_to_ismn);

my $ismn = ean_to_ismn('9790001012966');

Upvotes: 3

Related Questions