Business::ISBN(3)
π NAME π
Business::ISBN β the module that lets you hang out with International Standard Book Numbers like the absolute queen of cataloguing you are. π
Ok bestie, settle in, because this is literally the module for ISBN-10 and ISBN-13 shenanigans.
β¨ 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;
πΈ DESCRIPTION πΈ
This module handles International Standard Book Numbers, and yes that includes both ISBN-10 and ISBN-13. No book left behind. π
The data comes from Business::ISBN::Data, which means β slay β you can update the data separately from the code. Also, you can point Business::ISBN::Data at whatever RangeMessage.xml you like if you've got updated data. Go read that module for the deets. π
π§ Function interface π§
valid_isbn_checksum( ISBN10 | ISBN13 )β this one is exportable on demand, and it works for either 10 or 13 character ISBNs (yes, the original says "ISBNs)" with a stray paren, we're keeping the vibes).
use Business::ISBN qw( valid_isbn_checksum );
Here's the vibe check on what it hands back:
- Returns
1if the ISBN is a valid ISBN with the right checksum. π - Returns
0if the ISBN has valid prefix and publisher codes, but an invalid checksum. π - Returns
undefif the ISBN does not validate for any other reason. π
π Object interface π
new($isbn)β the constructor, aka where the main character enters. It accepts a scalar representing the ISBN.
The string representing the ISBN may contain characters other than "[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 $obj->error to something other than GOOD_ISBN. An object is still returned, and it is up to the program to check the error method for one of five values, or one of the error_* methods to check for a particular error. 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 %Business::ISBN::ERROR_TEXT hash, which is exportable by asking for it explicitly in the import list:
use Business::ISBN qw(%ERROR_TEXT);
As of version 2.010_01, you can get this text from error_text so you don't have to import anything. Iconic behaviour honestly. β¨
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 fix_checksum() 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 is_valid() 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 valid_isbn_checksum() function which is exportable on demand.
Heads up: if the constructor decides it cannot create an object, it returns undef. 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. Not even a little. π«
π Instance methods π
input_isbnβ returns the starting ISBN. Since you may insert hyphens or fix checksums, you might want to see the original data. Like a baby photo but for strings. πΌcommon_dataβ returns the starting ISBN after normalization, which removes anything that isn't a digit or a valid checksum character.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, tryas_string.
The isbn method should be the same as as_string( [] ).
errorβ return the error code for the reason the ISBN isn't valid. The return value is a key in%ERROR_TEXT.error_is_bad_grouperror_is_bad_publishererror_is_article_out_of_rangeerror_is_bad_checksum
These return true if the ISBN error is that type. π΅οΈβοΈ
error_textβ returns a text version of the error text.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. It's giving fully certified. βtypeβ returns either"ISBN10"or"ISBN13".prefixβ returns the prefix for the ISBN. This is currently either978or979for ISBN-13. It returns the empty string (so, a defined value) for ISBN-10.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 fromBusiness::ISBN::Data.groupβ returns the group name for the ISBN. This is the string version. For instance,'English'for the'0'group. The names come fromBusiness::ISBN::Data.publisher_codeβ returns the publisher code for the ISBN. This is the numeric version, for instance'596'for O'Reilly Media.article_codeβ returns the article code for the ISBN. This is the numeric version that uniquely identifies the item.article_code_lengthβ returns the article code length for the ISBN.article_code_minβ returns the minimum article code length for the publisher code.article_code_maxβ returns the max article code length for the publisher code.checksumβ returns the checksum code for the ISBN. This checksum may not be valid since you can create an object and fix the checksum later withfix_checksum.is_valid_checksumβ returnsBusiness::ISBN::GOOD_ISBNfor valid checksums andBusiness::ISBN::BAD_CHECKSUMotherwise. This does not guarantee that the rest of the ISBN is actually assigned to a book. Lowkey important distinction bestie. π«Άfix_checksumβ checks the checksum and modifies the ISBN to set it correctly if needed.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'.
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 prefix978, it returns the ISBN-10 equivalent. For all other cases it returnsundef. No notes. π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 the978prefix.incrementβ returns the nextBusiness::ISBNby incrementing the article code of the specified ISBN (object or scalar).
Returns undef, if the parameter is invalid or equals the maximum possible ISBN for the publisher.
$isbn = Business::ISBN->new('1565922573'); # 1-56592-257-3
$next_isbn = $isbn->increment; # 1-56592-258-1
If the next article code would exceed the maximum possible article code (such as incrementing 999 to 1000), this returns ARTICLE_CODE_OUT_OF_RANGE as the error.
decrementβ returns the previousBusiness::ISBNby decrementing the article code of the specified ISBN (object or scalar).
Returns undef, if the parameter is invalid or equals the minimum possible ISBN for the publisher.
$isbn = Business::ISBN->new('1565922573'); # 1-56592-257-3
$prev_isbn = $isbn->decrement; # 1-56592-256-5
If the next article code would exceed the maximum possible article code (such as incrementing 000 to -1), this returns ARTICLE_CODE_OUT_OF_RANGE as the error.
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 GD::Barcode::EAN13.
π BUGS π
Nothing listed here, bestie β the page just goes straight into the to-do list below.
β TO DO β
- i would like to create the bar codes with the price extension
π SOURCE AVAILABILITY π
This source is in Github:
https://github.com/briandfoy/business-isbn
π AUTHOR π
brian d foy "<briandfoy@pobox.com>"
π COPYRIGHT AND LICENSE π
Copyright Β© 2001-2026, brian d foy <briandfoy@pobox.com>. All rights reserved.
This module is licensed under the Artistic License 2.0. See the LICENSE file in the distribution, or https://opensource.org/licenses/Artistic-2.0
π«Ά CREDITS π«Ά
- Thanks to Mark W. Eichin
"<eichin@thok.org>"for suggestions and discussions on EAN support. - Thanks to Andy Lester
"<andy@petdance.com>"for lots of bug fixes and testing. - Ed Summers
"<esummers@cpan.org>"has volunteered to help with this module. - Markus Spann
"<markus_spann@gmx.de>"addedincrementanddecrement.
And that's the whole thing, bestie β this page is from perl v5.42.2, dated 2026-05-13, and it lives in the User Contributed Perl Documentation section as Business::ISBN(3). Go forth and validate. πβ¨
π¦ where this page comes from
- fedora 43: perl-Business-ISBN 3.014-1.fc43 Β· Artistic-2.0
- fedora 44: perl-Business-ISBN 3.014-1.fc44 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms