in reply to Re: Adding an element of an array as a key for a Hash, and remaining elements as its value (would also be a hash)
in thread Adding an element of an array as a key for a Hash, and remaining elements as its value (would also be a hash)

Thank you Monk! That totally worked. I guess I should have tried the curly braces! Thank you very much for pointing out. This really helps!

The next question I have is how did this work and not the one I tried ? Could you please explain to me? There is something that I have to learn about these braces

  • Comment on Re^2: Adding an element of an array as a key for a Hash, and remaining elements as its value (would also be a hash)

Replies are listed 'Best First'.
Re^3: Adding an element of an array as a key for a Hash, and remaining elements as its value (would also be a hash)
by AnomalousMonk (Archbishop) on Apr 12, 2016 at 02:37 UTC
    ... something that I have to learn about these braces

        $MasterHash{$mvr} = { map { split /:/; } @array1 };
                            ^     ^            ^         ^
                            |     |            |         |
                            |     + sub block  +         |
                            |                            |
                            + anon hash ref constructor  +
    See perlref for anonymous reference constructors (in particular, Making References section 3 for the anon hash ref constructor) and also perlreftut. See map for the function of the sub(routine) block.


    Give a man a fish:  <%-{-{-{-<

      Thank you very much AnomalousMonk. I will do some reading and understand deeper. This is very useful. I appreciate your time and efforts to explain it to me!

Re^3: Adding an element of an array as a key for a Hash, and remaining elements as its value (would also be a hash)
by Anonymous Monk on Apr 12, 2016 at 02:44 UTC

    also map in scalar context produces a count of the number of elements instead of the list of elements