in reply to Find element in array
Do you mean the current index of @DNA when looping?
TIMTOWTDI!
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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Find element in array
by Sofie (Acolyte) on Feb 16, 2020 at 13:25 UTC |
In Section
Seekers of Perl Wisdom