in reply to removing duplicate lines
use strict; use warnings; our @lines = <DATA>; chomp @lines; our %uniques; @uniques{@lines} = (); print "$_\n" for keys %uniques; __END__ Name1 Name2 Name2 Name3 Name3 Name3 Name3 Name4 Name4 Name5 Name5 Name5 Name5 Name5 Name6 Name6 Name7 Name7 Name7 Name8 Name8 Name9 Name9 Name9
Gives
Name8 Name9 Name1 Name2 Name3 Name4 Name5 Name6 Name7
Adding a sort to the print ... line like this
print "$_\n" for sort keys %uniques;
corrects the problem (assuming your "names" are real names that sort lexically, as going on to Name10, Name11 etc sort after Name1 and before Name2).
Cheers,
JohnGG
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: removing duplicate lines
by Not_a_Number (Prior) on Apr 10, 2006 at 19:34 UTC | |
by johngg (Canon) on Apr 10, 2006 at 22:14 UTC | |
by johngg (Canon) on Apr 10, 2006 at 22:53 UTC | |
by revdiablo (Prior) on Apr 10, 2006 at 23:19 UTC | |
by johngg (Canon) on Apr 11, 2006 at 08:55 UTC | |
by revdiablo (Prior) on Apr 11, 2006 at 16:24 UTC | |
| |
|
Re^2: removing duplicate lines
by Anonymous Monk on Apr 10, 2006 at 19:16 UTC |