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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Find element in array
by tobyink (Canon) on Feb 17, 2020 at 13:58 UTC | |
by LanX (Saint) on Feb 17, 2020 at 14:42 UTC | |
Re^3: Find element in array
by Sofie (Acolyte) on Feb 16, 2020 at 14:56 UTC | |
by LanX (Saint) on Feb 16, 2020 at 18:01 UTC |
In Section
Seekers of Perl Wisdom