Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^3: Using 'keys' on a list (update x2)

by LanX (Saint)
on Jun 30, 2021 at 12:32 UTC ( [id://11134487]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Using 'keys' on a list
in thread Using 'keys' on a list

> no, list in scalar context returns the last value

That's wrong.

A comma separated list returns the last value in scalar context, otherwise it always depends on the operator.

update

surrounding a LIST with (...)[-1] is a reliable way to get the last element

DB<7> x (1..5)[-1] 0 5 DB<8>

update

see also

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^4: Using 'keys' on a list (update x2)
by Anonymous Monk on Jun 30, 2021 at 14:38 UTC
    That's wrong.

    got an example of a "list in scalar context" or "comma operator in scalar context" or whatever that returns something other than the last value? wantarray is cheating

       sub f { %hash }
      - Ron
        that's the same as scalar(%hash) not scalar(list), try again

Log In?
Username:
Password:

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

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

    No recent polls found