Paper Stacks : pop « Array « Perl






Paper Stacks

   

#!/usr/bin/perl
use warnings;
use strict;
my $hand;
my @pileofpaper = ("A", "B", "C", "D");

print "@pileofpaper\n";
$hand = pop @pileofpaper;
print "$hand\n";
$hand = pop @pileofpaper;
print "$hand.\n";
print "@pileofpaper\n";
pop @pileofpaper;
print "$hand\n";
push @pileofpaper, $hand;
push @pileofpaper, "E", "F";
print "@pileofpaper\n";

   
    
    
  








Related examples in the same category

1.The pop function pops off the last element of an array and returns it.
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