in reply to Re: Re: Matching First Character of Strings Efficiently
in thread Matching First Character of Strings Efficiently
Sorry Limbic~Region, I got carried away with your "Only modify this line" (and had a brainfart too!).
There is no point in looping over the array, that's why we put in a hash. It should have looked something like this.
my @list = ...; my %list; @list{ map{ substr $_, 0, 1 } @list } = (); my $str_a = 'Foo'; expensive_function($str_a , $str_b) unless exists $list{ substr $str_a, 0, 1 };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Matching First Character of Strings Efficiently
by Limbic~Region (Chancellor) on Mar 15, 2004 at 22:35 UTC | |
by BrowserUk (Patriarch) on Mar 16, 2004 at 00:07 UTC |