Right track, but still too much work being done in the loop!
my @choices = qw/Apple Banana Tiger Lion Cat Turtle/; my @Single = qw/Apple Turtle/; my @Double = qw/Lion/; my %flags = ( map { $_ => 1 } @Single ), ( map { $_ => 2 } @Double ); for my $choice (@choices) { my $flag = $flags{$choice} || 0; print "$choice => $flag\n"; }
In reply to Re^2: The most efficient way for searching for an element in an array?
by ikegami
in thread The most efficient way for searching for an element in an array?
by Ppeoc
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |