#!/usr/bin/perl -w if (luhn()==0) { print "valid\n"; } else { print "not valid\n"; } sub luhn { 1 2 3 4 5 6 7 8 9 10 11 12 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012 $n='4564123800603607';$o=$_=reverse$n;$o=~s/.(.)/$1*2/ge;s/(.)./$1/ge;$o=~s/(.)/$x+=$1/ge;s/(.)/$y+=$1/ge;return($x+$y)%10; }