in reply to Re: Re: counting occurances
in thread counting occurances

Hi there!

Just a few mistakes:

<FILE>; # ignore first line my @words = (A, C, G, T); #letters to search my @file = do {local $/; split (//, <FILE>); }; #split each letter int +o an array foreach $file (@file){ foreach $words (@words){ if ($file eq $words){ $word_list{$file}++; } } } @pairs = sort {$a->[1] <=> $b->[1]} map {[ $_ => $word_list{$_}]} keys %word_list; print "word $_->[0] = $_->[1]\n" for @pairs;


You were only splitting on the first line of the file, and there was a typo on the last line. The code above will hopefully work as you intended.