ehm I think I saw this effect before, but can someone explain the values in @list?
DB<126> \%count => { 3 => 1, 5 => 1, 10 => 3 } DB<127> @list= %rcount= reverse %count => (3, 10, 3, 10) DB<128> \%rcount => { 1 => 3, 3 => 10 } DB<129> \@list => [3, 10, 3, 10]
to exclude problems with my repl
lanx@nc10-ubuntu:~$ perl -MData::Dumper -e ' %h1=(3 => 1, 5 => 1, 10 = +> 3 ); @l=%h2=reverse %h1; print Dumper \@l,\%h2' $VAR1 = [ 3, '10', 3, '10' ]; $VAR2 = { '1' => '3', '3' => '10' }; lanx@nc10-ubuntu:~$ perl -version This is perl, v5.10.0 built for i486-linux-gnu-thread-multi
bug or undefined behavior? reproducible in which versions?
lanx@nc10-ubuntu:~$ perl -MData::Dumper -e ' %h1=(3 => 1, 5 => 1, 10 = +> 3 ); %h4=%h3=%h2=reverse %h1; print Dumper \%h2,\%h3,\%h4' $VAR1 = { '1' => '3', '3' => '10' }; $VAR2 = { '3' => '10' }; $VAR3 = { '3' => '10' };
Cheers Rolf
( addicted to the Perl Programming Language)
In reply to assignment to hash with duplicates in list context (bug?) by LanX
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |