Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Find element in array

by LanX (Archbishop)
on Feb 16, 2020 at 12:43 UTC ( #11113021=note: print w/replies, xml ) Need Help??


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

    es the current index of the @DNA. I want to have a warning for each position of an element in the array that contains an invalid character. And then count the number of invalid characters.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11113021]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2020-03-29 10:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    To "Disagree to disagree" means to:









    Results (169 votes). Check out past polls.

    Notices?