Help for this page

Select Code to Download


  1. or download this
    perl -le'$m=1;$s+=$_*($m^=2)for(split(//,$ARGV[0]));
    print(($s%10)?"BAD":"OK");'
    
  2. or download this
    sub check_upc
    {
    ...
      return (($s%10)?"Invalid checkdigit; should be @{[10-($s-chop($upc))
    +%10]}"
                     :undef);
    }