I don't get it. When Purity=0 DD, doesn't claim to reevaluate correctly and it's frequently more readable. When Purity=1, it seems to work perfectly for me.
Here's something that takes your examples above, DDDumps them with Purity=1 and reevals the string and then shows the Streamer version of the original and of the evaled.
use Data::Dumper;
use Data::Dump::Streamer;
$Data::Dumper::Purity=1;
my ($x,$y);
$x=\$y;
$y=\$x;
test([$x, $y]);
my $ary=[];
$ary->[0]=\$ary->[1];
$ary->[1]=\$ary->[0];
test($ary);
sub test
{
my $VAR1;
my $s = shift;
my $d = Dumper($s);
my $s2 = eval "$d;\$VAR1";
die $@ if $@;
print "original---------------\n";
print Dump($s);
print "DDed---------------\n";
print Dump($s2);
print "\n"
}
__END__
original---------------
$ARRAY1 = [
\do { my $v = 'V: $ARRAY1->[1]' },
\do { my $v = 'V: $ARRAY1->[0]' }
];
${$ARRAY1->[0]} = $ARRAY1->[1];
${$ARRAY1->[1]} = $ARRAY1->[0];
DDed---------------
$ARRAY1 = [
\do { my $v = 'V: $ARRAY1->[1]' },
\do { my $v = 'V: $ARRAY1->[0]' }
];
${$ARRAY1->[0]} = $ARRAY1->[1];
${$ARRAY1->[1]} = $ARRAY1->[0];
original---------------
$ARRAY1 = [
'R: $ARRAY1->[1]',
'R: $ARRAY1->[0]'
];
$ARRAY1->[0] = \$ARRAY1->[1];
$ARRAY1->[1] = \$ARRAY1->[0];
DDed---------------
$ARRAY1 = [
\do { my $v = 'V: $ARRAY1->[1]' },
\do { my $v = 'V: $ARRAY1->[0]' }
];
${$ARRAY1->[0]} = $ARRAY1->[1];
${$ARRAY1->[1]} = $ARRAY1->[0];
The first one comes out identical. The second one is not textually identical but if ${$x} = $y means the same thing as $x = \$y then I can't see what DD did wrong. Do they mean the same thing?
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, 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, 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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
|
|