#!/usr/bin/perl -w
use strict;
#
# birth-numbers/validator.pl - slovak birth numbers validator & generator
#
# Developed by Ondrej Jombik <nepto@platon.sk>
# Copyright (c) 2002-2003 Platon SDG, http://platon.sk/
# Licensed under terms of GNU General Public License.
# All rights reserved.
#
# $Platon$
#
# Heavily used at 28/11/2002 - yeah, that was
# the deathline of ODM members completization
#
while (<STDIN>) {
chomp;
my $num = defined $_ ? $_ : '';
$num =~ s/\D//g;
if ( !length($num) ) {
print 'INVALID; no numbers entered', "\n";
next;
}
$num = int($num);
my $diff = $num % 11;
if ( !$diff ) {
print 'VALID', "\n";
next;
}
print 'INVALID; ';
if ( length($num) < 2 ) {
print 'number cannot be changed', "\n";
next;
}
my $last_num = int( substr( $num, -1 ) );
$last_num += 11 if ( $last_num - $diff < 0 );
$last_num -= $diff;
print 'change last number to ', $last_num, "\n";
}
Platon Group <platon@platon.sk> http://platon.sk/
|