Skip to content

personnummer/perl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

perl-personnummer

Validate Swedish personal identification numbers with Perl

Usage

Install with cpanm (or your preferred tool).

#!/usr/bin/env perl

user warnings;
use strict;

use Personnummer;

my $pnr = Personnummer->new( $ARGV[0] );

if ( !$pnr->valid() ) {
    die "Invalid personal identity number";
}

my $gender = $pnr->is_female() ? "female" : "male";

printf( "The person with personal identity number %s is a %s of age %d\n",
    $pnr->format(), $gender, $pnr->get_age() );