With your my
declaration in the foreach loop you declared the hash locally.
So the values you put into it weren't known outside.
With using strict something like this can't happen because perl will give you an error.
Have a look here for something more on my.
You can also do a Super Search