Validating BlackBerry PIN Codes…
By Andrey Butov
A customer misinterpreting the BlackBerry device PIN during checkout is a common occurrence for those processing BlackBerry software purchases. If you are interested in validating BlackBerry PINs on your servers during checkout, the following bit of code (Perl) may be of some use:
my $pin = <get PIN from submitted web page data>
return “Error” if !defined($pin);
$pin = &trimAndUpper($pin);
# Test for length validity.
return “Error” unless length($pin) == 8;
# Test for hex validity.
return “Error” unless ($pin =~ /^[[:xdigit:]]+$/);
# Good PIN at this point.
sub trimAndUpper {
my ($str) = @_;
$str =~ s/^\s+//; # left trim
$str =~ s/\s+$//; # right trim
$str =~ tr/a-z/A-Z/; # to upper
return $str;
}
