Some structures of mine aren't making the Dumper-eval trip successfully. I can't work out why (although the uninitialized warning looks bad).
Any ideas?

Here's a short test. There's a longer one in the readmore.

perl -w -MData::Dumper -d \ -e '$Data::Dumper::Purity=1;' \ -e '$a={ type => "int" }; $b = \$a->{type};' \ -e '$c= [$b,$a];' \ -e '$d=$d= eval Dumper($c);' DB<1> c Use of uninitialized value in scalar dereference at (eval 3)[-e:4] lin +e 4. Debugged program terminated. ... DB<1> x $d 0 ARRAY(0x8306864) 0 SCALAR(0x83068c4) -> 'int' 1 HASH(0x83068a0) 'type' => undef <<<<<<<<<<<<<<<< hey? DB<2> x $c 0 ARRAY(0x82f3fac) 0 SCALAR(0x80f621c) -> 'int' 1 HASH(0x8306af8) 'type' => 'int'
The longer example:
#!perl -w use Data::Dumper; $Data::Dumper::Purity=1; $a = { type => 'int' }; $b = \$a->{type}; print "\n[\$b,\$a]\n"; print Dumper([$b,$a]); eval Dumper([$b,$a]); print "\nevalled [\$b,\$a]\n"; print Dumper($VAR1); print Dumper([$b,$a]) eq Dumper($VAR1) ? "equal\n" : "NOT equal\n"; print "\n[\$a,\$b]\n"; print Dumper([$a,$b]); eval Dumper([$a,$b]); print "\nevalled [\$a,\$b]\n"; print Dumper($VAR1); print Dumper([$a,$b]) eq Dumper($VAR1) ? "equal\n" : "NOT equal\n"; __END__ [$b,$a] $VAR1 = [ \'int', { 'type' => ${$VAR1->[0]} } ]; Use of uninitialized value in scalar dereference at (eval 1) line 4. evalled [$b,$a] $VAR1 = [ \'int', { 'type' => undef } ]; NOT equal [$a,$b] $VAR1 = [ { 'type' => 'int' }, do{my $o} ]; $VAR1->[1] = \$VAR1->[0]{'type'}; evalled [$a,$b] $VAR1 = [ { 'type' => 'int' }, do{my $o} ]; $VAR1->[1] = \$VAR1->[0]{'type'}; equal

Brad


In reply to Data::Dumper scalar refs undef by bsb

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.