use strict; use warnings; my @array = <>; my @uniq; my %hash; for (@array) { push @uniq, $hash{$_} = $_ unless exists $hash{$_}; } print @uniq;