my @newarray = do { my %temphash; @temphash{@array1} = (); delete @temphash{@array1}; keys %temphash; };