in reply to Count the occurance of a words in a string

qw ($chromosomefilename); doesn't do what you think it does. There's no interpolation inside qw. Furthermore, do you really want to search in the filename? Perhaps you want to search in the filecontent, but since you have removed all whitespace, I wonder what your intend of the qw is.

If you just want to know whether ACGT is present, just use the grep or ack utility.