Business::ISBN(3pm) | User Contributed Perl Documentation | Business::ISBN(3pm) |
Business::ISBN - work with International Standard Book Numbers
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;
This modules handles International Standard Book Numbers, including ISBN-10 and ISBN-13.
The data come from Business::ISBN::Data, which means you can update the data separately from the code. Also, you can use Business::ISBN::Data with whatever RangeMessage.xml you like if you have updated data. See that module for details.
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.
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.
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.
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.
The "isbn" method should be the same as "as_string( [] )".
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'.
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.
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.
This requires "GD::Barcode::EAN13".
* i would like to create the bar codes with the price extension
This source is in Github:
https://github.com/briandfoy/business-isbn
brian d foy "<bdfoy@cpan.org>"
Copyright © 2001-2021, brian d foy <bdfoy@cpan.org>. 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
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>" added "increment" and "decrement".
2021-01-23 | perl v5.32.0 |