in reply to Interesting Use of Grep
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>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Interesting Use of Grep
by japhy (Canon) on Jun 28, 2001 at 19:06 UTC | |
by AidanLee (Chaplain) on Jun 28, 2001 at 19:33 UTC | |
by jynx (Priest) on Jun 29, 2001 at 01:04 UTC | |
by AidanLee (Chaplain) on Jun 29, 2001 at 02:44 UTC | |
by jynx (Priest) on Jun 30, 2001 at 02:59 UTC | |
by Anonymous Monk on Jun 29, 2001 at 18:59 UTC |