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


in reply to What is wrong in this code???

tr/// can be used to count characters in a string. No need to loop through.

use warnings; use strict; print "LATCG-\n"; while(<DATA>) { print $. . tr/A// . tr/T// . tr/C// . tr/G// . tr/-// . "\n"; } __DATA__ ATGAAAAAGAC AGCTATCGCGA TTGCAGTGGCA CTGGCTGGTTT CGCTACCGTAG CGC-A---TAG

Output:

LATCG- 171120 232330 323240 405240 522430 621224