- or download this
my $ismember = exists $hash{string};
- or download this
my %hash = map { $_ => $_ } @array;
print($hash{string1}, "\n");
print($hash{string2}, "\n");
print($hash{string3}, "\n");
- or download this
use List::Util qw( first );
my $idx = first { $array[$_] eq "string" } 0..$#array;
- or download this
sub ismember {
my ($array, $search) = @_;
...
}
my $idx = ismember(\@array, "string");