in reply to Re: removing duplicate lines
in thread removing duplicate lines
A more canonical (and efficient) way of preserving order, whether the input data is sorted or not, would be along the lines of:
my %seen; while ( <DATA> ) { s/\s+$//; # Remove trailing spaces and newline. print "$_\n" unless $seen{$_}++; }
By the way, why do you use our instead of my?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: removing duplicate lines
by johngg (Canon) on Apr 10, 2006 at 22:14 UTC | |
|
Re^3: removing duplicate lines
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 | |
by johngg (Canon) on Apr 12, 2006 at 09:20 UTC |