in reply to comparing a string with lots of other strings

use a hash if you have enough memory.
my @list1; my @list2; my %t; @t{@list2} = (); for ( @list1 ) { print "$_ found" if exists $t{$_}; }
Boris

Replies are listed 'Best First'.
Re^2: comparing a string with lots of other strings
by Tanktalus (Canon) on Jan 13, 2005 at 00:08 UTC

    I realise that the original question was comparing 300 strings to 5000. I'd like to just point out that using a hash like this is something I do even when comparing a handful of strings to, say, 50 strings. Much like The Force, hashes are useful for small and large problems. Doing a direct compare is only a good idea if one of the two lists to compare is a list of one. For lists of 2-5, it may be ok, but anything larger, I'd use the hash.