Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re^3: One-liner to join keys on a two-dimensionnal hash ?

by eyepopslikeamosquito (Bishop)
on Dec 29, 2021 at 23:20 UTC ( #11140027=note: print w/replies, xml ) Need Help??

in reply to Re^2: One-liner to join keys on a two-dimensionnal hash ?
in thread One-liner to join keys on a two-dimensionnal hash ?

I didn't know that map could be used such a way (i.e. having an output instead of altering every item in a list)

Erm, that is what map is for! :) Perl::Critic even provides a ProhibitVoidMap policy to warn you of code that uses map in void context.

I suggest you follow the simple stylistic advice given in Effective Perl Programming in the item "Use foreach, map and grep as appropriate" namely:

  • Use foreach to iterate read-only over each element of a list
  • Use map to create a list based on the contents of another list
  • Use foreach to modify elements of a list
  • Use grep to select elements in a list

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (1)
As of 2023-06-03 03:35 GMT
Find Nodes?
    Voting Booth?
    How often do you go to conferences?

    Results (6 votes). Check out past polls.