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

my @words = qw ($chromosomefilename); my $count = grep /$recognitionsequence/, @words;

So you're counting if $recognitionsequence matches the string $chromosomefilename (the literal string, not the contents of that variable). Is that what you want? If not, take it as a clue as to where start searching for errors.