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