Having a look at the forest with all those trees in the way...
Functionally, pop does 2 things:
1] removes the last element from an array and
2] returns that last element (for you to do things with)
Passing a literal array rather than a named variable means that the balance of the array is lost to the great bit-bucket in the sky immediately.
That means that the effect 1] above is lost.
That means that all you are
really doing is 2] - getting the last entry in a list.
and
that is very easily:
$x=[1,3,5,7,9]->[-1]
or
print [1,3,5,7,9]->[-1]
(Well, hard-coded like this, you may as well just grab the '9' and be done, but let's pretend this is auto-generated in an eval or something.)
HTH
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:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.