My data looks like this,
1 20010101 945 A 6
1 20010101 946 B 4
1 20010101 947 P 3.5
1 20010101 950 A 5
1 20010101 951 P 4
1 20010101 952 P 4
1 20010101 1010 A 4
1 20010101 1011 P 4
2 20010101 940 A 3.5
2 20010101 1015 A 3
2 20010101 1113 B 3.5
2 20010101 1114 P 3.2
2 20010101 1115 B 3.4
2 20010101 1116 P 3.1
2 20010101 1119 P 3.6
I am trying to find all the lines (with P) followed by the latest A and B values based on the matching of first two columns (e.g., 1 and 20010101).
The result is expected to be like this,
1 20010101 947 P 3.5 6 4
1 20010101 951 P 4 5 4
1 20010101 952 P 4 5 4
1 20010101 1011 P 4 4 4
2 20010101 1114 P 3.2 3 3.5
2 20010101 1116 P 3.1 3 3.4
2 20010101 1119 P 3.6 3 3.4
Does it need to sort by using hash in Perl? I am lack of ideas could anybody give any hint? I will be much appreciated!