use strict; use warnings; my @number = (1,2,3,9432, 5,6,7); my $count=0; for (0 .. (($#number < 99) ? $#number : 99)) { if ($number[$count]=~/^9432$/g) { print "match found\n"; } else { print "match failed\n"; } $count++; }