Contents


On-line Guides
All Guides
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems

How To Guides
General How To Guides
JavaScript How To
HTML How To
Problem Solutions

 

 

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.4.2.1 Arrays as Stacks

What more is a stack than an unbounded array of things? This attitude is seen in Perl through the push and pop functions. These functions treat the "right hand side" (i.e., the end) of the array as the top of the stack. Here is an example:

use strict; my @stack; push(@stack, 7, 6, "go"); # @stack is now qw/7 6 go/ my $action = pop @stack; # $action is "go", @stack is (7, 6) my $value = pop(@stack) + pop(@stack); # value is 6 + 7 = 13, @stack is empty




 
 
  Published under the terms of the GNU General Public License Design by Interspire