@items = qw(1 2 3 4 5 6 7 8 9);

$x = 6;
$i = -1;
$index = 0;
foreach (@items) {
    $i = $index, last if $x eq $items[$index];
    $index++;
}
print "$x was found at $i (-1 means it wasn't found)\n";