my @newarray = (); foreach my $i (@arrayindex) { unshift @newarray, (splice @array, $i); pop @array; }