in reply to Re: Determining if an element in a list
in thread Determining if an element in a list
In general, this is a pretty inefficient solution as you're searching the whole list every time. In the worst case you have a very long list and the element you're searching for is the first element.
Something like thoe following is better:
my $found; foreach (@list) { if (/$pattern/) { $found = 1; last; } }
But the solutions in the FAQ are even better.
--Perl Training in the UK <http://www.iterative-software.com>
|
|---|