use Data::Dumper; $Data::Dumper::Purity=1; use strict; my $array=[0,1]; $array->[0]=\$array->[1]; $array->[1]=\$array->[0]; print Dumper($array);
Which outputs
$VAR1 = [ \\do{my $o}, do{my $o} ]; ${${$VAR1->[0]}} = $VAR1->[0]; $VAR1->[1] = ${$VAR1->[0]};
So whats wrong with the ouput?

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>

<super>Highlight the above if you want the answer</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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.