in reply to pulling value based on input

It is also a good practice to check for the existence of hash keys, particularly when prompting for input via the keyboard:
if (exists $locs{$loc}) { # do something... } else { die "key $loc does not exist"; }

Update: I should have read mscharrer's node more closely, as this was already mentioned. But, I provided the link to the docs, so I guess this is not completely redundant.