in reply to Quicker Array Searching
my @things = qw/homer bart marge maggie lisa kramer jerry george elaine marge lisa/; my %seen; foreach my $thing ( @things ) { next if exists $seen{$thing}; $seen{$thing}++; # Do your stuff here. }
The above snippet keeps track of whether or not something's been seen already, and if it has, it skips to the next thing. If it hasn't seen it before, it makes a note of that thing, and then lets you do whatever processing you want.
The hash lookup is much faster than grep on an array.
Dave
|
|---|