Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2015-11-30 10:42 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (769 votes), past polls