[Koha-cvs] CVS: koha/C4 Input.pm,1.1.1.1.2.1,1.1.1.1.2.2

Alan Millar amillar at users.sourceforge.net
Fri Jun 14 08:28:16 CEST 2002


Update of /cvsroot/koha/koha/C4
In directory usw-pr-cvs1:/tmp/cvs-serv17073/C4

Modified Files:
      Tag: rel-1-2
	Input.pm 
Log Message:
Move checkvalidisbn subroutine to Input.pm

Index: Input.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Input.pm,v
retrieving revision 1.1.1.1.2.1
retrieving revision 1.1.1.1.2.2
diff -C2 -r1.1.1.1.2.1 -r1.1.1.1.2.2
*** Input.pm	25 Apr 2002 21:59:55 -0000	1.1.1.1.2.1
--- Input.pm	14 Jun 2002 06:28:14 -0000	1.1.1.1.2.2
***************
*** 10,14 ****
  
  @ISA = qw(Exporter);
! @EXPORT = qw(&checkflds &checkdigit);
   
  sub checkflds {
--- 10,16 ----
  
  @ISA = qw(Exporter);
! @EXPORT = qw(
! 	&checkflds &checkdigit &checkvalidisbn
! );
   
  sub checkflds {
***************
*** 50,55 ****
    }
    return $valid;
! }
   
  END { }       # module clean-up code here (global destructor)
-     
--- 52,93 ----
    }
    return $valid;
! } # sub checkdigit
! 
! #--------------------------------------
! # 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;
!         if (length($q)==10) {
!             my $checksum=substr($q,9,1);
!             my $isbn=substr($q,0,9);
!             my $i;  
!             my $c=0;
!             for ($i=0; $i<9; $i++) { 
!                 my $digit=substr($q,$i,1);
!                 $c+=$digit*(10-$i);
!             }
!             $c=int(11-($c/11-int($c/11))*11+.1);
!             ($c==10) && ($c='X');
!             if ($c eq $checksum) {
!                 $isbngood=1;
!             } else {
!                 $isbngood=0;
!             }
!         } else {
!             $isbngood=0;
!         } # if length good
! 
!         return $isbngood;
! 
! } # sub checkvalidisbn
! 
   
  END { }       # module clean-up code here (global destructor)





More information about the Koha-cvs mailing list