Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ] 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