codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
@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";
Private
[
?
]
Run code
Submit