If you look at perldoc for tr/SEARCHLIST/REPLACEMENTLIST/cdsr , you will see the following at the bottom of the section:
Since the transliteration table is built at compile time, neither SEARCHLIST nor REPLACEMENTLIST are double-quoted. This means that if you want to use variables, you must use eval ():
eval "tr/$oldlist/$newlist/"; die $@ if $@ ; eval "tr/$oldlist/$newlist/, 1" or die $@ ;
So you need eval to create a new SEARCHLIST.
It will be very inefficient ... the code may seem neat, but you process the full line 26 times. You also do not count uppercase characters.
You'd better go over the line once and just increment the counts for each character found.
source share