CARVIEW |
Select Language
HTTP/2 200
server: nginx
content-type: text/plain;charset=UTF-8
content-encoding: gzip
content-security-policy: default-src 'self'; connect-src 'self' *.google-analytics.com; img-src 'self' data: www.google-analytics.com www.googletagmanager.com; script-src 'self' 'unsafe-inline' www.google-analytics.com www.googletagmanager.com; style-src 'self'; report-uri /csp-reports
accept-ranges: bytes
age: 0
date: Wed, 30 Jul 2025 20:10:28 GMT
via: 1.1 varnish
x-served-by: cache-bom-vanm7210036-BOM
x-cache: MISS
x-cache-hits: 0
x-timer: S1753906228.524161,VS0,VE885
vary: Accept-Encoding
strict-transport-security: max-age=31557600
content-length: 574
=over
=item shift ARRAY
X
=item shift
Removes and returns the B element of an array. This shortens the
array by one and moves everything down.
my @arr = ('cat', 'dog');
my $item = shift(@arr); # 'cat'
# @arr is now ('dog');
Returns C if the array is empty.
B C may also return C if the first element in the array
is C.
my @arr = (undef, 'two', 'three');
my $item = shift(@arr); # undef
If ARRAY is omitted, C operates on the C<@ARGV> array in the main
program, and the C<@_> array in subroutines. C will operate on the
C<@ARGV> array in C, C, C, C blocks.
Starting with Perl 5.14, an experimental feature allowed
C to take a
scalar expression. This experiment has been deemed unsuccessful, and was
removed as of Perl 5.24.
See also L|/unshift ARRAY,LIST>, L|/push ARRAY,LIST>,
and L|/pop ARRAY>. C and
L|/unshift ARRAY,LIST> do the same thing to the left end of
an array that L|/pop ARRAY> and L|/push ARRAY,LIST> do to
the right end.
=back