Help for this page

Select Code to Download


  1. or download this
    @a = (12, 18, 56, 76, 99);
    $in = <STDIN>;
    ...
       die "found at $_\n" if $in == $a[$_];
    }
    print "not found\n";
    
  2. or download this
    @a = (12, 18, 56, 76, 99);
    $in = <STDIN>;
    sub{die "found at $_\n" if $in == $a[$_]}->() for(0..$#a);
    print "not found\n";
    
  3. or download this
    @a = (12, 18, 56, 76, 99);
    $in = <STDIN>;
    ...
       $i = $_ if $in == $a[$_];
    }
    $i == 0 ? print "not found\n" : print "found at $i\n";