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;
In reply to state preserving uniq by Chady
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |