2 7 18 ggcgt anna
2 7 18 hhchc sam
3 7 18 hhdjcc ross
4 7 18 hhcjd jenny
0 8 21 jjdhs sam
3 8 21 kkok bush
2 9 24 kosss Brenham
If the values of the second column are equal, print only those lines with the least first column value. So in this example, the value 7 is same is in the first 4 lines; and the least first column value among those lines is 2. so I want only the first 2 lines.
desired output is,
2 7 18 ggcgt anna
2 7 18 hhchc sam
0 8 21 jjdhs sam
2 9 24 kosss Brenham
I tried this code but getting all kinds of errors.
Thanks a bunch for your replies. I was trying run the script from perl file rather than from the command line and I am getting "uninitialized values $i" in the first code and same error for multiple variables in the second code. Can you please provide the same code in the script mode.
I am beginner of perl and I have been banging my head since today morning to write this script. If possible, can you guys explain the codes briefly ? I really appreciate your help. Thanks again.
want to do your homework.
It's not the first case, because you want specifically a perl solution. I can't say it is the second because you don't know about 'my' construction - and you can't learn anything without knowing elementary things. So you don't want to learn perl and it can be suggested that you just want to get a solution for your exercise. Ok, maybe someone will want to do it for you but it's just not me.
Its actually both 1 and 2. I am trying to finish the work by using/learning perl. I know about "my" construction. But I thought of it as an option as mentioned in the 'basic' perl book. While I appreciate your first reply in this thread, based on your replies in past threads and the second reply in this thread, I reckon you are very judgmental and your comments are presumptuous. Its not that I have not tried; I have provided the code. You either suggest something specific to the code or stay off. Thanks.