The "cafeteria with spring-loaded trays" model is exactly right for stacks (LIFOs - Last in, First out) which are what push and pop apply to. And yes, you absolutely would both push and "pop" trays - push to add em in the first place,and pop to get one to use.
Perl extends the concept to include access to the "bottom" of the "stack" which allows a few more operational models. In particular the combination of push and shift (or unshift and pop) provide a queue (FIFO - First in, First out). Shift parallels an operation common in handling arguments in some OS batch/scripting languages. Unshift is a neat complement to shift for "putting back" an argument after taking a peek at it. At times there is an advantage to using a queue where you can add and remove elements to/from either end - can't think of an example right now in the software world, but it often happens in supermarket checkout queues!
Nomenclature adjusted for northern hemisphere usage. In the southern hemisphere stacks are the other way up. Queues can be either way and may be affected by the Coriolis effect.
DWIM is Perl's answer to Gödel
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||