in reply to Re^3: how to change this code into perl
in thread how to change this code into perl

Sure, where there are two entries with the same key, it only prints the second one (the duplicate, not the original one); when there are three, it will print only the second one and the third one. And of course, it will work only if the lines are properly sorted.

If you need to print all the lines that are duplicates, then it is slightly more complicated, because you need to keep track of recent history. And then, yes, it is probably better to write a real script.

Another way is to use a hash to keep track of everything in memory.

  • Comment on Re^4: how to change this code into perl