Push, pop, shift and unshift an array : pop « Array « Perl






Push, pop, shift and unshift an array

   

#!/usr/bin/perl

use strict;
use warnings;

my @array = (1, 2, 3, 4, 5, 6);
push @array, '7';   
print "@array\n";   
my $last = pop @array; 
print "$last\n";   
unshift @array, -1, 0;
print "@array\n";  
shift @array;   
shift @array;   
print "@array\n";   

   
    
    
  








Related examples in the same category

1.Paper Stacks
2.The pop function pops off the last element of an array and returns it.
3.Pop value out of array
4.$s = pop @{[@a]};
5.Using Pop to remove element from an array