print join ' ', @return{ @keys };
Why would an assignment behave differently? And if it should include the keys, then what should happen if you said this?
( $foo, $bar, @return{ @keys } ) = 1 .. 10;
And perhaps can you give an example that doesn't use $_ with all its aliasing behaviour just adding to the noise.
The aliasing behaviour isn't noise, it is exactly the point. The aliasing behaviour makes a difference because the assignment returns the list of lvalues that were assigned to. If the assignment returned copies, then nothing in the original array would change. Let's do that again, but making sure to pass copies this time:
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
my %return;
my @value = qw( foo bar baz quux );
$_ = uc $_
for @{ [ @return{ qw( a b c d ) } = @value ] };
print Dumper( \%return ), Dumper( \@value );
=begin output
$VAR1 = {
'c' => 'baz',
'a' => 'foo',
'b' => 'bar',
'd' => 'quux'
};
$VAR1 = [
'foo',
'bar',
'baz',
'quux'
];
This time, the changes are lost in the mist of time, because we didn't operate on the list of lvalues assigned to, we operated on copies of their values.
Makeshifts last the longest. |