Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

nested unbless of Data::Dumper output

by coke4all (Novice)
on Mar 20, 2013 at 09:54 UTC ( #1024487=perlquestion: print w/replies, xml ) Need Help??
coke4all has asked for the wisdom of the Perl Monks concerning the following question:

Hi there,

iv the following problem. Ive created a nested Object Oriented Moose Object '$X' which consists itself of further Sub-Objects. One of the Sub-Objects '$y' is placed more than once within '$X'.

My aim now is to print out a PLAIN representation of the object '$X'.

At the moment i do this with:

my $plain = Dumper(unbless($X));

Generally this works, but the problem is that ive left one reference variable '$VAR1 = {...}' in this output ($plain). The reason is that ive the Sub-Object '$y' more than once within the Object '$X'.

Does anybody know how to avoid this?

Replies are listed 'Best First'.
Re: nested unbless of Data::Dumper output
by Eliya (Vicar) on Mar 20, 2013 at 11:19 UTC

    Not entirely sure I understand what you need, but if the idea is to avoid cross references being created, you might want to try $Data::Dumper::Deepcopy = 1;

    For the following sample structure, the difference in output would be

    my $y = { foo => "bar" }; my $X = { a => $y, b => $y, c => $y }; $Data::Dumper::Deepcopy = 1; print Dumper($X);
    $VAR1 = { 'c' => { 'foo' => 'bar' }, 'a' => { 'foo' => 'bar' }, 'b' => { 'foo' => 'bar' } };

    while the default output (Deepcopy=0) would look like

    $VAR1 = { 'c' => { 'foo' => 'bar' }, 'a' => $VAR1->{'c'}, 'b' => $VAR1->{'c'} };

      Thanks, this is exactly what i needed!!!

Re: nested unbless of Data::Dumper output
by Anonymous Monk on Mar 20, 2013 at 10:35 UTC

    What is the problem?

    Where do you get unbless, maybe you want circular_off?

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2018-06-23 23:46 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.