I Found the error, a missing $ sign in line
$value1 = $hash1{key1};. I am using use strict;, how come it did not detect that?
If there any other way to optimize my code?. thanks
Stricture didn't catch it because it isn't an error. Perl does a nifty bit of DWIMery when you use a bareword as a hash key and just uses the string as a key, so you're creating a key called "key1".