how to parse contents in a column in a file

hi all,

i am facing this problem ,please help.

suppose a file contains conetnts as below:

john itemspurchased/date
john itempurchased/date
james itempurchased/date
john items purchsed/date

so here i want to store john only once in a variable but retreive his 3 corresponding data (items purchesd with date). i. e i want to store each value in the 1st column once only.

need ur help urgently.....
thanks in advance

Are you expecting something like this ??

awk '{a[$1]=a[$1]"\n"$2} END { for (i in a){ print i "-->" a} }' inputfile.txt

the above command is showing errors when used in perl script.

is there a way to do this using perl script.

show your Perl script. Or is it you haven't got one?

Whenever someone specifically requests a mode for solution - in this case to provide a perl script - is a big signal that this is likely homework.

Our Rules do not allow assistance with homework.
The UNIX and Linux Forums - Forum Rules

thanks for your solution....it worked and every doubt is a homework:D