awk and perl grouping.

Hello folks.

After awk, i have decided to start to learn perl, and i need some help.

I have following output :

1 a
1 b
2 k 
2 f
3 s 
3 p

Now with awk i get desired output by issuing :

awk ' { a[$1] = a[$1] FS $2 } END { for ( i in a) print i,a }' input
1  a b
2  k f
3  s p

Can someone shed a light how to do this operation in perl since i have zero exp in it.

Thank you very much for your assistance.

Best regards
Peasant.

You could try using the a2p (awk to perl) tool. Its output may help you in your learning with this and other problems.

If I'm not mistaken, there's also a sed to perl translator, s2p.

Regards,
Alister