The shift function in Perl will remove the first value of the array passed to it and return it.

my @names = ('Foo', 'Bar', 'Moo');
my $first = shift @names;
print "$first\n";     # Foo
print "@names\n";     # Bar Moo

Note, the array itself got shorter. The first element was removed from it!

shift without parameters

In case no array is passed to it, shift has two defaults depending on the location of shift.

If shift is outside any function it takes the first element of @ARGV (the parameter list of the program).

examples/shift_argv.pl

use strict;
use warnings;

my $first = shift;
print "$first\n";

$ perl examples/shift_argv.pl one two
one

If shift is inside a function it takes the first element of @_ (the parameter list of the function).

examples/shift_in_sub.pl

use strict;
use warnings;


sub something {
	my $first = shift;
	print "$first\n";
}

something('hello', 'world');

$ perl examples/shift_in_sub.pl one two
hello

Here shift disregarded the content of @ARGV and took the first element of @_, the array holding the parameters passed to the function.

Shift on empty array

If the array shift works on is empty, then shift will return undef.

Regardless if the array was explicitely given to it or implicely selected based on the location of shift.

See video explaining shift and unshift or the example using shift to get first parameter of a script.