in reply to Extracting single element from array to be printed in a one liner hash

if($key{$data} eq $input){
If you had used strict (tip #1 from the Basic debugging checklist), you'd have gotten an error regarding the %key variable. Perhaps you meant...
if($data{$key} eq $input){

See also Writeup Formatting Tips. Use "code" tags.