Which outputsuse Data::Dumper; $Data::Dumper::Purity=1; use strict; my $array=[0,1]; $array->[0]=\$array->[1]; $array->[1]=\$array->[0]; print Dumper($array);
So whats wrong with the ouput?$VAR1 = [ \\do{my $o}, do{my $o} ]; ${${$VAR1->[0]}} = $VAR1->[0]; $VAR1->[1] = ${$VAR1->[0]};
|
In the original there are 3 variables involved. $array, $array->[0] and $array->[1] In the output there are 5 variables involved. In fact the ouput is syntactically equivelent to (and Dumper will ouput both arrays the same) my ($x,$y); $x=\$y; $y=\$x; my $array=[$x,$y]; Which of course contains 5 variables $array, $array->[0], $array->[1], $x and $y This can be verified by $array->[1]='funky!'; print ${$array->[0]}; Which will print 'funky!' for the original input, but not for the ouput, nor for the second example. <super>(code in one line to avoid CSS styles overriding the no-spoiler)</super>
|
You didnt peek before answering did you?
;-)
Yves / DeMerphq
---
Writing a good benchmark isnt as easy as it might look.
<super>UPDATE:Forgot the Purity setting on first post.</super>
In reply to Puzzle: Whats wrong with Dumper by demerphq
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |