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