in reply to Finding unique elements in inputs

I've been watching this thread for the last day or so. The problem with your code has been identified. You've received a number of working solutions, all of which I've upvoted.

Having said that, all solutions here seem more complicated than is necessary. To my mind, the following is really all you need:

$ perl -e ' my %seen; my @values = grep !$seen{$_}++, @ARGV; print "@values\n"; ' 1 2 1 2 3 1 2 3 1 2 3

There are a number of ways this can be shortened. Here are a couple of examples:

$ perl -E ' local $, = " "; say grep {state $seen; !$seen->{$_}++} @ARGV; ' 1 2 1 2 3 1 2 3 1 2 3
$ perl -E 'say "@{[grep {state $seen; !$seen->{$_}++} @ARGV]}";' 1 2 1 + 2 3 1 2 3 1 2 3

However, there are potential drawbacks to these:

— Ken