Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Avoiding the "Encountered CODE ref" message when using Data::Dumper

by alain_desilets (Beadle)
on Sep 12, 2011 at 19:26 UTC ( #925553=perlquestion: print w/replies, xml ) Need Help??
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/ 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?


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 (Pope) on Sep 12, 2011 at 19:38 UTC
    local $Data::Dumper::Deparse = 1;
    local $SIG{__WARN__} = sub { print(STDERR $_[0]) if $_[0] !~ /^Encountered CODE ref, using dummy placeholder/; };

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://925553]
Approved by Corion
Front-paged by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (2)
As of 2018-01-18 04:47 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (206 votes). Check out past polls.