sub test { my $a = shift; die "Malformed value '$a'" if ($a !~ /(.)(.)(.)(..)(.+)/); my ($first,$second,$third,$fourth) = ($1,$2,$3,$4); return 0 if ($first !~ /(a)/); return 0 if ($second !~ /(d|p|t)/); return 0 if ($third !~ /(a|h|r|s|t)/); return 0 if ($fourth !~ /(aw|er|dd|cb|aa)/); }