my @list = ; LINE: foreach my $line (@list) { if ($line =~ /(^|\s)the(\s|$)/i) { print "$line"; } else { next LINE; } }