in reply to Re^2: Combinations of lists, etc
in thread Combinations of lists to a hash

That's not my code. You replied to the wrong person/post (and no glob in this one).

No idea. Sorry.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Replies are listed 'Best First'.
Re^4: Combinations of lists, etc
by tel2 (Pilgrim) on Oct 05, 2019 at 01:58 UTC
    Sorry LanX - I got mixed up.
    I've updated my last post now with your code.
      Please try to understand how the code works, especially the loop with the two nested maps °

      Your desired changes are trivial then.

      I did the demo in the debugger to help you experiment. Please use strict and warnings when translating into a script.

      We are glad to answer your questions.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

      °) could also be translated into a 3 level for loop if it's easier to understand for you.

        Thanks LanX.

        I'm trying to modify your code to handle update #2 in my original post, i.e. this line:

        @hash{@keys} = ('value2') x @keys
        This test seems to work as I want it to:
        perl -MData::Dump -e '@hash{(key1,key2)} = ({a=>1, b=>2},{a=>1,b=>2}); +dd \%hash' { key1 => { a => 1, b => 2 }, key2 => { a => 1, b => 2 } }
        But when I try to multiply the values out, it doesn't:
        perl -MData::Dump -e '@hash{(key1,key2)} = ({a=>1, b=>2}) x 2;dd \%has +h' do { my $a = { key1 => { a => 1, b => 2 }, key2 => 'fix' }; $a->{key2} = $a->{key1}; $a; }
        And the debugger didn't shed any light for me, either.
        What am I doing wrong, please?  And what's that 'fix' thing about?