![]() |
|
good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Why does ‘keys’ need a named hash?by ankitpati (Sexton) |
on Apr 05, 2017 at 11:55 UTC ( #1187094=perlquestion: print w/replies, xml ) | 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 work, but not? Edit: 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?
Back to
Seekers of Perl Wisdom
|
|