in reply to Fringe case slice behavior
That would be extremely inconsistent indeed, as @hash{'a'..'c'} is supposed to be equivalent to ($hash{'a'}, $hash{'b'}, $hash{'c'}). And it is. What I get for \%hash, with Data::dumper, for both, is:This has the effect of assigning 2 to $hash{'c'}. ...the last element in the slice.my %hash = ('a'=>1, 'b'=>1, 'c'=>1); @hash{'a'..'c'} = 2;
both with 5.6.1 and with 5.8.0 (though the order might vary). <sigh-of-relief/>. So it is consistent.$VAR1 = { 'a' => 2, 'b' => undef, 'c' => undef };
Code used for testing:
my %hash = ('a'=>1, 'b'=>1, 'c'=>1); @hash{'a'..'c'} = 2; use Data::Dumper; print Dumper \%hash; %hash = ('a'=>1, 'b'=>1, 'c'=>1); ($hash{'a'}, $hash{'b'}, $hash{'c'}) = 2; print Dumper \%hash;
|
|---|