foreach $element ( @array2 ) { if ( not $seen{$element} ++ ) { push( @array1, $element ); } }