foreach $item (@pos) { unless ($seen{$item}) { # if we get here we have not seen it before $seen{$item} = 1; push (@uniq, $item); } }