The shift function shifts off and returns the first element of an array, decreasing the size of the array by one element.
#If ARRAY is omitted, then the ARGV array is shifted, and, if in a subroutine, the @_ array is shifted.
# Removing elements from front of a list
@names=("Bob", "Dan", "Tom", "Guy");
$ret = shift @names;
print "@names\n";
print "The item shifted is $ret.\n";
Related examples in the same category