Help for this page

Select Code to Download


  1. or download this
    $foobar='D';
    $sep = chr(1);
    ...
    if (($sep.join($sep,@array).$sep) =~ m/$sep$foobar$sep/) {
       print "Found a $foobar in \@array!";
    }
    
  2. or download this
    $foobar='D';
    %hash = ( 'A' => undef, 'B' => undef, 'C' => undef, 'D' => undef );
    print "Found a $foobar in \%hash" if exists $hash{$foobar};
    
  3. or download this
    @array = ('A','B','C','D');
    for (@array) {
    ...
    if (exists $hash{$foo}) {
       print "There was a $foo in the array\n";
    }