koha-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Koha-cvs] CVS: koha/C4 Input.pm,1.4,1.5


From: Andrew Arensburger
Subject: [Koha-cvs] CVS: koha/C4 Input.pm,1.4,1.5
Date: Mon, 23 Sep 2002 06:53:49 -0700

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

Modified Files:
        Input.pm 
Log Message:
Added POD.


Index: Input.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Input.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** Input.pm    14 Aug 2002 18:12:51 -0000      1.4
--- Input.pm    23 Sep 2002 13:53:47 -0000      1.5
***************
*** 27,35 ****
  $VERSION = 0.01;
  
  @ISA = qw(Exporter);
  @EXPORT = qw(
        &checkflds &checkdigit &checkvalidisbn
  );
!  
  sub checkflds {
    my ($env,$reqflds,$data) = @_;
--- 27,55 ----
  $VERSION = 0.01;
  
+ =head1 NAME
+ 
+ C4::Input - Miscellaneous sanity checks
+ 
+ =head1 SYNOPSIS
+ 
+   use C4::Input;
+ 
+ =head1 DESCRIPTION
+ 
+ This module provides functions to see whether a given library card
+ number or ISBN is valid.
+ 
+ =head1 FUNCTIONS
+ 
+ =over 2
+ 
+ =cut
+ 
  @ISA = qw(Exporter);
  @EXPORT = qw(
        &checkflds &checkdigit &checkvalidisbn
  );
! 
! # FIXME - This is never used.
  sub checkflds {
    my ($env,$reqflds,$data) = @_;
***************
*** 40,44 ****
      if ($data->address@hidden eq "") {
        push(@probarr, @$reqflds[$i]);
!     }  
      $i++
    }
--- 60,64 ----
      if ($data->address@hidden eq "") {
        push(@probarr, @$reqflds[$i]);
!     }
      $i++
    }
***************
*** 46,49 ****
--- 66,81 ----
  }
  
+ =item checkdigit
+ 
+   $valid = &checkdigit($env, $cardnumber);
+ 
+ Takes a card number, computes its check digit, and compares it to the
+ checkdigit at the end of C<$cardnumber>. Returns a true value iff
+ C<$cardnumber> has a valid check digit.
+ 
+ C<$env> is ignored.
+ 
+ =cut
+ #'
  sub checkdigit {
    my ($env,$infl) =  @_;
***************
*** 54,61 ****
    my $valid = 0;
    #  print $infl."<br>";
    while ($i <8) {
      my $temp1 = $weightings[$i-1];
      my $temp2 = substr($infl,$i,1);
!     $sum = $sum + ($temp1*$temp2);
  #    print "$sum $temp1 $temp2<br>";
      $i++;
--- 86,95 ----
    my $valid = 0;
    #  print $infl."<br>";
+   # FIXME - for ($i = 1; $i < 8; $i++)
+   # or      foreach $i (1..7)
    while ($i <8) {
      my $temp1 = $weightings[$i-1];
      my $temp2 = substr($infl,$i,1);
!     $sum += $temp1 * $temp2;
  #    print "$sum $temp1 $temp2<br>";
      $i++;
***************
*** 64,68 ****
    if ($rem == 10) {
      $rem = "X";
!   }  
    #print $rem."<br>";
    if ($rem eq substr($infl,8,1)) {
--- 98,102 ----
    if ($rem == 10) {
      $rem = "X";
!   }
    #print $rem."<br>";
    if ($rem eq substr($infl,8,1)) {
***************
*** 72,80 ****
  } # 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)address@hidden ;       # Input: ISBN number
  
--- 106,124 ----
  } # sub checkdigit
  
+ =item checkvalidisbn
+ 
+   $valid = &checkvalidisbn($isbn);
+ 
+ Returns a true value iff C<$isbn> is a valid ISBN: it must be ten
+ digits long (counting "X" as a digit), and must have a valid check
+ digit at the end.
+ 
+ =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)address@hidden ;       # Input: ISBN number
  
***************
*** 87,93 ****
              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);
--- 131,137 ----
              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);
***************
*** 95,98 ****
--- 139,143 ----
            $c=$c%11;  # % is the modulus function
              ($c==10) && ($c='X');
+             # FIXME - $isbngood = $c eq $checksum;
              if ($c eq $checksum) {
                  $isbngood=1;
***************
*** 101,104 ****
--- 146,152 ----
              }
          } else {
+             # FIXME - Put "return 0 if $length($q) != 10" near the
+             # top, so we don't have to indent the rest of the function
+             # as much.
              $isbngood=0;
          } # if length good
***************
*** 108,111 ****
  } # sub checkvalidisbn
  
-  
  END { }       # module clean-up code here (global destructor)
--- 156,173 ----
  } # sub checkvalidisbn
  
  END { }       # module clean-up code here (global destructor)
+ 
+ 1;
+ __END__
+ 
+ =back
+ 
+ =head1 AUTHOR
+ 
+ Koha Developement team <address@hidden>
+ 
+ =head1 SEE ALSO
+ 
+ L<perl>.
+ 
+ =cut




reply via email to

[Prev in Thread] Current Thread [Next in Thread]