for $i (0..$#array) { # just in case they change the number of months :) next unless ($month eq $array[$i]); # skip if not equal print "Yes its a month\n"; last; # no need to check other months so exit loop }