Here's a short test. There's a longer one in the readmore.
The longer example: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'
#!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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |