your code should work, as works mine in such situations
I can advice you following:
It is suspicious to "chop" each line, much better to "chomp" it, because, if last line of a file does not contain newline, your code will damage data.
Just right before assigning into registry by "$key{...}=..." perform debugging printout of key and value information and post it here again, I think this will help solving your problem
(this will not affect script behaviour here, but anyways, this could affect somewhere else) why do you assign a numeric value to a variable but then check it for string equality by "eq" operator?