in reply to Data::Dumper scalar refs undef
This gives you the following output:#!perl -w use Data::Dumper; $Data::Dumper::Purity=1; $a = { type => 'int' }; $b = \$a->{type}; print "case 1\n", Data::Dumper->Dump([$a, $b], [qw/a b/]); print "case 2\n", Data::Dumper->Dump([$a, $b], [qw/x y/]); print "case 3\n", Data::Dumper->Dump([$b, $a], [qw/b a/]); print "case 4\n", Data::Dumper->Dump([$b, $a]);
In other words, Data::Dumper is smart, but not 'that' smart. In case of dumping variables referencing each other, you have to use the extended Dump and optionally give it the names of your variables so it can distinguish them properly.case 1 $a = { 'type' => 'int' }; $b = \$a->{'type'}; case 2 $x = { 'type' => 'int' }; $y = \$x->{'type'}; case 3 $b = \'int'; $a = { 'type' => ${$b} }; case 4 $VAR1 = \'int'; $VAR2 = { 'type' => ${$VAR1} };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Data::Dumper scalar refs undef
by demerphq (Chancellor) on Sep 23, 2003 at 13:14 UTC |