Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

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/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
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;
    or
    local $SIG{__WARN__} = sub { print(STDERR $_[0]) if $_[0] !~ /^Encountered CODE ref, using dummy placeholder/; };

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://925553]
Approved by Corion
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2014-12-19 02:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (70 votes), past polls