alain_desilets has asked for the wisdom of the Perl Monks concerning the following question:

I am using Data::Dumper to save the state of a very deeply nested object to file. The nested structure contains:

A) Duplicate references to the same sub-components

B) References to functions

The problem I am having is that, in order for the duplicate references to be read correctly as duplicates, I have to set:
local $Data::Dumper::Purity = 1;
But then, when the dumper encounters the references to functions, it outputs the following message:

Encountered CODE ref, using dummy placeholder at C:/Perl/lib/Data/Dumper.pm line 190.

If I set Purity to undef, then that message does not appear, but then the duplicate references are read as separate instances.

Is there a way around this issue?

Thx

Alain Désilets
  • Comment on Avoiding the "Encountered CODE ref" message when using Data::Dumper
  • Download Code

Replies are listed 'Best First'.
Re: Avoiding the "Encountered CODE ref" message when using Data::Dumper
by ikegami (Patriarch) on Sep 12, 2011 at 19:38 UTC
    local $Data::Dumper::Deparse = 1;
    or
    local $SIG{__WARN__} = sub { print(STDERR $_[0]) if $_[0] !~ /^Encountered CODE ref, using dummy placeholder/; };