in reply to Elegantly dereferencing multiple references

FWIW it's possible in one statement but hardly "elegant"
use strict; use warnings; use Data::Dump; my %x = ( a => "red"); my %y = ( b => "green"); my %z = ( c => "black"); sub assign { my (%x, %y, %z) = ( %{$_[0]}, %{$_[1]}, %{$_[2]} ); dd \(%x, %y, %z); }

I'll post later a more elegant but significantly slower solution

UPDATE:
I was wrong, never mind. Thanks to Eily++

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

Replies are listed 'Best First'.
Re^2: Elegantly dereferencing multiple references
by Eily (Monsignor) on May 13, 2016 at 12:31 UTC

    I was wondering what trick you used to prevent the flattened list to go into the first hash only. Looks like there's none:

    $VAR1 = { 'c' => 'black', 'a' => 'red', 'b' => 'green' }; $VAR2 = {}; $VAR3 = {};

      oops you are right, I had various outputs from Data::Dump and only saw what I expected to see... :-/

      Cheers Rolf
      (addicted to the Perl Programming Language and ☆☆☆☆ :)
      Je suis Charlie!

Re^2: Elegantly dereferencing multiple references
by LanX (Saint) on May 13, 2016 at 13:44 UTC
    as compensation an even less elegant (read uglier) attempt for a one liner:

    sub assign { %$_ = %{shift @_} for \ (my (%a, %b, %c)); dd ["assign", \(%a, %b, %c) ]; } assign( \(%x, %y, %z));

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!