A variation of this code passed by today (written by a perl coder), and it is confusing:
my $k = {3,5,6,8};
my $y = {%$k};
Why? What does that do? That seems to be the same thing as this:
my $y = $k;
The context is in a call using dbi module:
while (my $x = $db->fetchrow_hashref )
{ $y{something} = {%$x}; }
The difference is that it’s cloning the data structure without referencing the same memory.
For example:
Incidentally, manually initialising a hash by using all commas (as in
my $k = {3,5,6,8}) is very, very ugly.