#!/usr/bin/perl

use strict;
my @stuff;
my $i;
my $temp;


@stuff=qw< bill joe sue mary harry >;

for($i=0;$i<=$#stuff;$i++)
{
print "$i $stuff[$i]\n";

}

# popping an empty list.array returns undef
#
# popping an element from a list/array removes the element from the END (the
# high index)

$temp=pop(@stuff);
print "Popped value is $temp\n";
for($i=0;$i<=$#stuff;$i++)
{
print "$i $stuff[$i]\n";

}

# pushing an element onto a list/array places the new element at the END
# (the high index)

push(@stuff,"larry");
push(@stuff,"matilda");
print "\n\nafter 2 pushes\n";
for($i=0;$i<=$#stuff;$i++)
{
print "$i $stuff[$i]\n";

}

# shift and unshift operate on the start (left) side
# shift removes (returns) the element at the zero index and shifts everything down
# unshift adds an element at index zero, but first shifts everything up by one

$temp=shift(@stuff);
print "Here's the shifted value: $temp\n";
print "\n\nafter 1 shift\n";
for($i=0;$i<=$#stuff;$i++)
{
print "$i $stuff[$i]\n";

}

unshift(@stuff, "New Person");
print "\n\nafter 1 UNshift\n";
for($i=0;$i<=$#stuff;$i++)
{
print "$i $stuff[$i]\n";

}