Try taking out the single quotes around $key when setting up the hash. When using single quotes around a variable name like '$key' the value returned is not the contents of $key but the characters '$', 'k', 'e', 'y' themselves. You could use double quotes but that is not necessary. Just use