if ($str =~ m/\d[a-zA-Z]\d+/) { print "Ok!\n"; } else { print "Invalid format! Must be: [digit][letter][digit][digit] ... \n"; }