Last active
August 25, 2016 17:12
-
-
Save BanzaiMan/7fceafa1819fb149ac0d7eb3d8137ebb to your computer and use it in GitHub Desktop.
Why does this Perl one-liner does not drop the last dupe?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ echo x:x:y:y:z:x:y:z | perl -e 'print join(":", grep { !$seen{$_}++ } split(/:/, scalar <>))' | |
x:y:z:z |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It is supposed to remove all duplicate entries in a
:
-delimited list while preserving the order in which unique components appear.