in reply to Find element in array

Do you mean the current index of @DNA when looping?


The traditional way with your code is to use an explicit counter:

my $idx=-1; for my $nucleotide (@DNA){ $idx++; ... }

But you can also apply while / each on arrays

while ( my ($idx, $nucleotide) = each @DNA){ ... }

(I tapped this message into a mobile, no guaranty for the code.)

HTH! :)

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery