411 REFERENCE · Wikibooks
Perl Programming/Keywords/shift
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
Perl setsockopt shmctl Keywords
The shift keyword
shift shifts the first value of the array off and returns it, shortening the array by 1 and moving everything down. If the array is empty, undef is returned. Without ARRAY, it shifts @_ within the lexical scope of formats and subroutines.
From Perl 5.14 onward, shift can take a scalar EXPRESSION that must hold a reference to an unblessed array. The argument will be dereferenced automatically. This aspect of shift is considered highly experimental, and the exact behaviour may change in a future version of Perl.
Syntax
shift ARRAY
shift EXPRESSION
shift
Example
unshift(@ARGV, '-e') unless $ARGV[0] =~ /^-/;
See also
unshift
Perl setsockopt shmctl Keywords