Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: passing an array without a name to pop()

by The_Dj (Beadle)
on Dec 04, 2019 at 06:45 UTC ( [id://11109647]=note: print w/replies, xml ) Need Help??


in reply to passing an array without a name to pop()

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11109647]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2024-04-19 04:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found