Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to make Data::Printer show stringified values in internals?
    primarykey
    data
    text
    <p>I have some complex object structures, and I use Data::Printer to inspect them. One case where it's not helpful enough is this: when an object (container) has a field that's another object (child), the child shows up in DDP's output only as class name. I wish to also see the stringified value of the child.</p> <p>Let's have an example:</p> <pre><code>{ package Child; use Moo; use overload '""' =&gt; "stringify"; has 'value', is =&gt; 'ro'; sub stringify { my $self = shift; return "&lt;Child:" . $self-&gt;value . "&gt;"; } } { package Container; use Moo; has 'child', is =&gt; 'ro'; } my $child_x = Child-&gt;new(value =&gt; 'x'); print "stringified child x: $child_x\n"; my $child_y = Child-&gt;new(value =&gt; 'y'); print "stringified child y: $child_y\n"; my $container_x = Container-&gt;new(child =&gt; $child_x); my $container_y = Container-&gt;new(child =&gt; $child_y); use DDP; print "ddp x: " . p($container_x) . "\n"; print "ddp y: " . p($container_y) . "\n"; </code></pre> <p>Output:</p> <pre><code>stringified child x: &lt;Child:x&gt; stringified child y: &lt;Child:y&gt; ddp x: Container { Parents Moo::Object public methods (2) : child, new private methods (0) internals: { child Child # &lt;- note this } } ddp y: Container { Parents Moo::Object public methods (2) : child, new private methods (0) internals: { child Child # &lt;- and this } } </code></pre> <p>As you see, the children are indistinguishable in the output. I'd like to see the stringification in that place, either in addition to or instead of the class name.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload