If the list of values that you are matching against is large then this method can get pretty inefficient. Remember that grep always checks every element of the array. In cases like that, it would be more efficient to do something like this:
--my $found = 0; foreach (@long_list_of_values) { if ($var eq $_) { $found = 1; last; } } if ($found) { # do something... }
Perl Training in the UK <http://www.iterative-software.com>
In reply to Re: Interesting Use of Grep
by davorg
in thread Interesting Use of Grep
by AidanLee
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |