results in the already observed behaviourperl -MData::Dumper -e "for (1 .. 6){print join('.',%h = (1) x $_) . \ +"\n\";print Dumper(\%h)}"
whereas1 $VAR1 = { '1' => undef }; 1.1 $VAR1 = { '1' => 1 }; 1..1 $VAR1 = { '1' => undef }; 1..1.1 $VAR1 = { '1' => 1 }; 1..1..1 $VAR1 = { '1' => undef }; 1.1.1..1.1 $VAR1 = { '1' => 1 };
results inperl -MData::Dumper -e "for (1 .. 6){%h=(1) x $_;print join('.',%h ) . + \"\n\";print Dumper(\%h)}"
which is correct. The question would seem to me to be "why is the 'x' operator propogating to the join?". My guess is that the join is executed for every iteration of the "x", i.e. every time the assignment is triggered %h is updated and the join is executed. (BTW, the undef values are correct and to be expected - see the Dumper results above).1. $VAR1 = { '1' => undef }; 1.1 $VAR1 = { '1' => 1 }; 1. $VAR1 = { '1' => undef }; 1.1 $VAR1 = { '1' => 1 }; 1. $VAR1 = { '1' => undef }; 1.1 $VAR1 = { '1' => 1 }
rdfield
In reply to Re: Erm? Bug or not? Weird behaviour in hash / list conversion
by rdfield
in thread Erm? Bug or not? Weird behaviour in hash / list conversion
by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |