in reply to Re^4: how to change this code into perl
in thread how to change this code into perl
I tried the script and its printing all the rowsThen you have to show me your input data. I've just tried that script with the following input data:
and it print only the lines where the first column is a duplicate, as shown in this output:aa blah bb blah bb blahblah bb foo cc dlqskjf cc cfkqs dd dkls ee dsjkqjs ff blah gg klsqdj gg sqkl
This seems to work perfectly.bb blah bb blahblah bb foo cc dlqskjf cc cfkqs gg klsqdj gg sqkl
Otherwise, the way it works is that it reads the file one line at a time, and store this line ($previous_line), as well as the comparison key until the next line is read. If they have the same key, then I print the previous line (if defined) and the current one; in such case, I undef the previous line to prevent it from being printed twice if there are triplicates.
If it does not work properly for you, please show your input and/or test data.
|
|---|