removes duplicate lines like UNIX uniq without having to sort the lines first, and preserves the line positions keeping the first match in the list.
#!/usr/bin/perl while (<>) { next if (defined $list{$_}); $list{lc($_)} = [ $i++, $_ ]; } print map { $_->[1] } sort { $a->[0] <=> $b->[0] } values %list;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: state preserving uniq
by xmath (Hermit) on Mar 01, 2003 at 10:54 UTC | |
by Aristotle (Chancellor) on Mar 01, 2003 at 17:28 UTC | |
by xmath (Hermit) on Mar 01, 2003 at 17:39 UTC | |
by Chady (Priest) on Mar 01, 2003 at 12:16 UTC | |
by Anonymous Monk on Mar 01, 2003 at 15:58 UTC | |
by xmath (Hermit) on Mar 01, 2003 at 16:22 UTC | |
Re: state preserving uniq
by steves (Curate) on Mar 01, 2003 at 12:13 UTC | |
Re: state preserving uniq
by Intrepid (Curate) on Jul 30, 2003 at 19:02 UTC |