http://www.perlmonks.org?node_id=1059012


in reply to If/else within a foreach loop to check strings within an array

It is possible to have more than non-standard nucleotide in your sequence? If so, you might consider looking for all the non-matches:
#!/usr/bin/perl use warnings; use strict; my $dna_input = shift; my @dna = split( '', $dna_input ); my (@index) = grep { $dna[$_] !~ /[ATCG]/ } 0..$#dna; print "Non-nucleotide at position $_\n" for @index;