|more useful options|
Why does ‘keys’ need a named hash?by ankitpati (Acolyte)
|on Apr 05, 2017 at 11:55 UTC||Need Help??|
ankitpati has asked for the wisdom of the Perl Monks concerning the following question:
The perldoc on keys clearly states
Called in list context, returns a list consisting of all the keys of the named hash…but makes no attempt to explain why.
Googling around for an explanation also yielded no results.
Put very simply, why does
I express my sincerest thanks to the monks for a warm welcome into the monastery.
Following the suggestions, I tried
which works perfectly fine.
However, prior to this, even before I posted the question, I experimented with
and it did not work.
I had always believed that braces can convert a list with even number of elements into a valid HASHref, and modulo (%) can convert any valid HASHref into a hash.
The question now is this: if map just produces a list, why does it need two pairs of braces to emit a valid HASHref?