Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
executable file 43 lines (38 sloc) 937 Bytes
#! /usr/bin/perl
use strict;
use warnings;
# Write a program to validate given Vehicle Identification Number (VIN).
my %cvalue;
map {$cvalue{$_}=$_} (0..9);
my $base=ord('A');
foreach my $char ('A'..'H','J'..'N','P','R') {
foreach my $char ('S'..'Z') {
my $valid=join('',keys %cvalue);
my @weight=reverse (2..9,0,10,2..8);
foreach my $vin (@ARGV) {
unless (length($vin)==17) {
print "$vin is not 17 characters\n";
unless ($vin =~ /^[$valid]*$/) {
print "$vin contains invalid characters\n";
my $check=0;
foreach my $ix (0..16) {
if ($check==10) {
if (substr($vin,8,1) ne $check) {
print "$vin does not pass check-digit verification (may be valid non-NA)\n";
print "$vin is valid.\n";
You can’t perform that action at this time.