Help for this page

Select Code to Download


  1. or download this
    my @list = qw/ frog turtle tadpole /;
    my $find = "turtle";
    ...
    if( grep { $_ eq $find } @list ) {
        print "Found $find.\n";
    }
    
  2. or download this
    my $found_flag = 0;
    foreach my $item ( @list ) {
    ...
    if( $found_flag ) {
        print "Found $find.\n";
    }
    
  3. or download this
    use List::Util;
    
    ...
    if( first { $_ eq $find } @list ) {
        print "I found it!\n";
    }