my $index = 0; my $i = 0; my $key = 10; my @array = .... my $success = grep {$array[$_] eq $key && ($in = $_)} 0..$#array; $success is 0 if not found, 1 if found $in contain the offset index