I threw your code into my editor and threw in use strict. Most looks fine, but the %catReplace hash doesn't get initialized anywhere I can see - would this matter? The other obvious possibility is that you've got whitespace problems. Have you tried seeing if length returns the expected values?
Thank you all for the help. Was not a coding problem but a converting problem. I now truely hate CSV files. Added a newline break which i got rid of and another unknown character I just used substr to get rid of.