#arrays as stacks my @stack1 = qw/this is a good feature/; print "initial array contains : @stack1\n"; push(@stack1,"in"); print "@stack1\n"; push(@stack1,"perl"); print "@stack1\n"; my $var = pop(@stack1); print "$var popped of arraystack which now contains : @stack1\n"; push(@stack1, 7); push(@stack1, 8); $var = pop(@stack1) + pop(@stack1); print"$var\n"; #arrays as queues print "@stack1\n"; unshift(@stack1,"thing"); print "@stack1\n"; foreach(@stack1){ my $qq = pop(@stack1); print "$qq popped from end of queue\n"; print "left on stack : @stack1 \n"; print "stack size is $#stack1 \n"; } #### ##output initial array contains : this is a good feature this is a good feature in this is a good feature in perl perl popped of arraystack which now contains : this is a good feature in 15 this is a good feature in thing this is a good feature in in popped from end of queue left on stack : thing this is a good feature stack size is 5 feature popped from end of queue left on stack : thing this is a good stack size is 4 good popped from end of queue left on stack : thing this is a stack size is 3 a popped from end of queue left on stack : thing this is stack size is 2 C:\Documents and Settings>