use strict; use warnings; my @choices = qw/Apple Banana Tiger Lion Cat Turtle/; my @Single = qw/Apple Turtle/; my @Double = qw/Lion/; my %Single_hash = map {$_ => 1} @Single; my %Double_hash = map {$_ => 1} @Double; foreach my $choice (@choices) { my $flag = exists $Single_hash{$choice} ? 1 : exists $Double_hash{$choice} ? 2 : 0 ; print "$choice => $flag\n"; }
In reply to Re: The most efficient way for searching for an element in an array?
by BillKSmith
in thread The most efficient way for searching for an element in an array?
by Ppeoc
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |