LanX has asked for the wisdom of the Perl Monks concerning the following question:
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)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: assignment to hash with duplicates in list context (bug?)
by kcott (Archbishop) on Sep 25, 2013 at 02:04 UTC | |
|
Re: assignment to hash with duplicates in list context (bug?)
by tinita (Parson) on Sep 25, 2013 at 01:16 UTC | |
by Anonymous Monk on Sep 25, 2013 at 02:11 UTC | |
|
Re: assignment to hash with duplicates in list context (accidents)
by tye (Sage) on Sep 25, 2013 at 01:19 UTC | |
by LanX (Saint) on Sep 25, 2013 at 01:35 UTC | |
|
Re: assignment to hash with duplicates in list context (bug?)
by choroba (Cardinal) on Sep 25, 2013 at 01:14 UTC | |
|
Already discussed
by LanX (Saint) on Sep 25, 2013 at 01:45 UTC |