shift() is a built in Perl subroutine that takes an array as an argument, then returns and deletes the first item in that array. It is common practice to obtain all parameters passed into a subroutine with shift calls. For example, say you have a subroutine foo that takes three arguments. One way to get these parameters assigned to local variables is with shift like so:
sub foo() {
my $x = shift;
my $y = shift;
my $z = shift;
# do something
}
The confusion here is that it appears shift is not being passed an array as an argument. In fact, it is being passed the "default" array implicitly, which is @_ inside a subroutine or @ARGV outside a subroutine.
In Perl, many methods use the default variables ($_ and @_) if you don't explicitly specify arguments. Your code is identical to:
my $x = shift @_;
As pointed out by PullMonkey earlier, within a subroutine, @_ contains the arguments passed to that subroutine (as described in perlsub). shift will remove the first argument value from @_ and store it in $x, so $_[0] will now give you the second argument passed to your subroutine.
In layman's terms, from a very highlevel view, shift is taking the first element of an array (the leftmost part), while the opposite is pop which is taking the last element of array (the rightmost part).
my @array1=(5,6,7,8,9);
my $x = shift @array1;
print "$x\n"; # 5
print "@array1\n"; # 6 7 8 9
Do you still have questions after reading the output of perldoc -f shift?
(That is not a question; it is an answer ;-))
Another recommended reading is man perlbook.
Perl "shifts off" the first element from @_, returning it.
So $x is assigned to the first element of @_ after removing it from there.
@_ itself are the routine parameters.
So these three are common alternatives (not the very same, however):