The shift function shifts off and returns the first element of an array, decreasing the size of the array by one element. : shift « Array « Perl






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

1.Shift and Unshift
2.Using shift the get value out of an array
3.Shift value from array
4.shift array
5.While there are more elements in @array, remove each element with shift