--- name: shift status: documented runtime: pp source: src/runtime/pp/aggregate.rs --- ```{index} single: shift; Perl built-in (pp runtime) ``` # shift ## Synopsis ```perl my $val = shift @array; my $arg = shift; # shifts from @_ inside a sub, @ARGV at top level ``` ## Description Removes and returns the first element of an array, shifting all remaining elements down by one index. Removes the first element from the array, shifts all remaining elements down by one, and returns the removed element. Returns `undef` if the array is empty. When the SPECIAL flag is set (bare `shift` without an explicit array), the implicit target depends on call context: inside a subroutine it reads from `@_` (pad slot 0); at file scope it reads from `@ARGV`. Handles both regular `Av` and `AliasedAv` (the typical representation of `@_`). ## See also unshift, pop, push, splice