in reply to Re: Find element in array
in thread Find element in array
Addendum: $. aka $INPUT_LINE_NUMBER will also give the current line number when reading from a file handle.
Update
use strict; use warnings; while (my $sequence = <DATA>) { chomp $sequence; if ($sequence =~ /[^ATCG]/){ warn "Sequence '$sequence' in line $. has invalid character af +ter " . $-[0]; } else { print "Valid sequence: '$sequence'\n"; } } __DATA__ TAAGAACAATAAGAACAA TAAGAACAATAAUAACAA TAAGAACAATAAGAACAA
Sequence 'TAAGAACAATAAUAACAA' in line 2 has invalid character after 12 at parse_dna.pl line 7, <DATA> line 2.
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
In Section
Seekers of Perl Wisdom