Subject: | Seen() recently broken |
Broken in: After version 2.121_04 (perl 5.8.7)
Fixed in: Still broken in version 2.121_08 (perl 5.8.8)
Issue:
init_refaddr_format() does not necessarily get called before Seen(),
causing Seen() to silently fail.
The following snippet demonstrates the problem:
-- BEGIN --
use Data::Dumper ();
my $foo = [1..5];
my $bar = [ [6..10], $foo ];
my $d = Data::Dumper->new([ $bar ], [ '$bar' ]);
$d->Seen({ '$foo' => $foo });
print $d->Dump();
-- END --
The following snippet demonstrates a workaround:
-- BEGIN --
use Data::Dumper ();
my $foo = [1..5];
my $bar = [ [6..10], $foo ];
Data::Dumper::init_refaddr_format() # Workaround
if *Data::Dumper::init_refaddr_format{CODE}; # Backwards compat
my $d = Data::Dumper->new([ $bar ], [ '$bar' ]);
$d->Seen({ '$foo' => $foo });
print $d->Dump();
-- END --
Solution:
Have init_refaddr_format() called sooner, such as when the module is loaded.