Help for this page

Select Code to Download


  1. or download this
    perl -e 'my @t=qw/banana plum apple strawberry pea/;my $fruit="apple";
    +print (($fruit~~\@t)?"yes":"no");'
    yes
    
  2. or download this
    perl -e 'my @t=qw/banana plum apple strawberry pea/;my $fruit="apple";
    +my %in;undef @in{@t};print ((exists $in{$fruit})?"yes":"no");'
    yes
    
  3. or download this
    perl -e 'my @t=qw/banana plum apple strawberry pea/;my $fruit="apple";
    +for my $f (@t) {next if $fruit ne $f;print "yes";last}'
    yes
    
  4. or download this
    #no, not efficient