perl -ane '$items{$F[0]} = $F[1] ;END{print "apples cost $items{apple}\n" if $items{apple}}' data #### #here you can also get the name from the user and print the #price.