--- name: splice status: documented runtime: pp source: src/runtime/pp/aggregate.rs --- ```{index} single: splice; Perl built-in (pp runtime) ``` # splice ## Synopsis ```perl my @removed = splice @array, $offset; my @removed = splice @array, $offset, $length; my @removed = splice @array, $offset, $length, @replacements; splice @array, 0, 0, @prepend; # insert at beginning ``` ## Description Removes and/or replaces elements in an array, returning the removed elements. Removes `$length` elements starting at `$offset` from `@array`, optionally replacing them with `@replacements`, and returns the removed elements. Negative `$offset` counts from the end of the array. If `$length` is omitted, removes everything from `$offset` onward. A negative `$length` leaves that many elements at the end. Replacement arrays are flattened. The array is rebuilt in place. ## See also push, pop, shift, unshift, delete