$count = $line =~ tr/ACGT//; # count only the ACGT characters in $line $line =~ tr/ACGT//cd; # remove all non-ACGT characters from $line