ISBN.pm

ISBN.pm is a perl module suitable for verifying and converting ISBNs.

Download

Download Here

Functions

convert($isbn)
Takes a 10 diget ISBN and returns the 13 diget equivalent. Does not perform any error checking or validation.

gettype($isbn)
Takes a string value and will make a guess as to whether or not it fits the criteria of an ISBN. Returns 10 for a possible ISBN-10 and 13 for ISBN-13. Does not validate further.

validateten($isbn)
Takes a 10 digit numeric value and checks to determain if it is a valid ISBN-10.

validatettn($isbn)
Takes a 13 digit digit numeric value and checks to determain if it is a valid ISBN-13.

genchksum13($isbn)
Takes a 12 digit numeric value and generates an ISBN-13 checksum digit.

genchksum10($isbn)
Takes a 9 digit numeric value and generates an ISBN-10 checksum digit.

printinvalid()
Returns a message informing the user the ISBN is invalid.

Example of Use

#!/usr/bin/perl
use ISBN;
$isbn="0123456789";
$isbntype=ISBN::gettype($isbn);
ISBN::printinvalid if ($isbntype < 1);

$isvalidten=ISBN::validateten($isbn) if ($isbntype ==10);

$isvalidttn=ISBN::validatettn($isbn) if ($isbntype ==13);

if ($isvalidten){print "That is a valid ISBN-10\n";}

elsif ($isvalidttn){print "That is a valid ISBN-13\n";}

else{ISBN::printinvalid}