The pop function pops off the last element of an array and returns it. : pop « Array « Perl






The pop function pops off the last element of an array and returns it.

   

The array size is subsequently decreased by 1.

# Removing an element from the end of a list
@names=("A", "B", "C", "D");
print "@names\n";
$got = pop(@names);   
print "$got\n";
print "@names\n";

   
    
    
  








Related examples in the same category

1.Paper Stacks
2.Pop value out of array
3.$s = pop @{[@a]};
4.Push, pop, shift and unshift an array
5.Using Pop to remove element from an array