my %hash; while (my $item = shift @list) { next if exists $hash{$item}++; . . }