Perl Stack Array

Program that prompts for string, pushes it onto an array.
Using an array as a stack in Perl.
The array structure in Perl can be used as more than just an accumulation of scalar values. It is also used as a stack, which is often a very convenient data abstraction.

Perl Stack Array

Diagram of a stack

Visualize a data stack as being like a stack of blocks.
The block at the bottom of the stack is array element 0, and the block at the top of the stack is the highest-numbered
element in the array. A stack is sometimes called a LIFO (last-in/first-out) data structure, because the most recently added data is always the first data retrieved.

The push function

The Perl function push is used to push a new value onto an array. In the following example,
the latest Academy Award-winner is added to the list: