Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Pondelok, 22. júl 2024

Súbor: [Platon] / scripts / perl / birth-numbers / validator.pl (stiahnutie)

Revízia 1.1, Sun Nov 9 19:22:05 2003 UTC (20 years, 8 months ago) by nepto

Slovak birth numbers validator and generator.

#!/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/
Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok