my $found; foreach (@list) { if (/$pattern/) { $found = 1; last; } }