#testhash.txt has a single line of text that reads: #'key1,value1','key2,value2','key3,value3','key4,value4' open(HASH,"testhash.txt"); $line=(); chomp $line; @list=($line); @list=('key1,value1','key2,value2','key3,value3','key4,value4'); print "here is \@list:\n"; print $list[0]; print $list[3]; print "\nEnter the keycode:"; chop ($find=); foreach (@list) { ($keycode,$keyvalue)=split /,/; #split up the array elements if ($find=~/$keycode/i) { print "Keycode $keycode has the value $keyvalue \n"; } }