Help for this page

Select Code to Download


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