#!/usr/local/bin/perl use strict; my %items; open (FD, "data" ) || die "unable to open file"; while (){ my @ar = split; $items{$ar[0]} = $ar[1]; } #here you can also get the name from the user and print the #price. print "price of apple is : ", $items{"apple"}, "\n";