my $goal = 'over'; my @array = qw(the quick fox jumped over the lazy dog); my $found; foreach my $item (@array) { if ($item =~ /$goal/) { $found = 1; # in case we need it later print $item; # do other stuff last; } }