use strict; use warnings; my $DNA = "ATATCCCGATCAGG3TT!GCA\n"; chomp $DNA; print "The length of the sequence is:\n", length($DNA), "\n"; my $nucleotideDNA = $DNA; #my $count = $nucleotideDNA =~ tr/ATCG]//c; # Remove and count invalids my $count = $nucleotideDNA =~ tr/ATCG//cd; # Remove and count invalids my $locations; # Find location of invalids in original string $locations .= "$-[0], " while ( $DNA =~ /[^ATCG]/g ); print "There are $count non-valid nucleotides at locations:\n$locations \n"; OUTPUT: The length of the sequence is: 21 There are 2 non-valid nucleotides at locations: 14, 17,