-=cut
-#'
-#--------------------------------------
-# Determine if a number is a valid ISBN number, according to length
-# of 10 digits and valid checksum
-sub checkvalidisbn {
- use strict;
- my ($q)=@_ ; # Input: ISBN number
-
- my $isbngood = 0; # Return: true or false
-
- $q=~s/x$/X/g; # upshift lower case X
- $q=~s/[^X\d]//g;
- $q=~s/X.//g;
-
- #return 0 if $q is not ten digits long
- if (length($q)!=10) {
- return 0;
- }
-
- #If we get to here, length($q) must be 10
- my $checksum=substr($q,9,1);
- my $isbn=substr($q,0,9);
- my $i;
- my $c=0;
- for ($i=0; $i<9; $i++) {
+sub checkvalidisbn ($) { # Obsolete Function!
+ my ($q) = shift or return undef;
+ $q=~s/[^Xx\d]//g;
+ /(\d{9})(X|\d)/i or
+ /(\d{12})(X|\d)/i or return 0;
+ my $checksum = $2;
+ my $isbn = $1;
+ my $c = 0;
+ my $max = length $isbn;
+ for (my $i=0; $i<$max; $i++) {