in reply to Filtering very large files using Tie::File
The following should be fast, it allows arbitrary large files, and it preserves order:
perl -ne'print "$.\t$_"' input.txt \ | sort -k 2 \ | uniq -f 1 \ | sort \ | cut -f 2- \ > output.txt [download]