Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re^2: Object Browser for Perl?

by QM (Parson)
on Jul 08, 2013 at 13:54 UTC ( #1043125=note: print w/replies, xml ) Need Help??

in reply to Re: Object Browser for Perl?
in thread Object Browser for Perl?

Examining objects, especially changes to objects between runs, is problematic because:

(1) There is a lot of data in an object, so complete Data::Dumper output runs hundreds or thousands of lines. I can reduce this with 'depth', but then runs may not be so easily compared, as truncated object trees end with 'key' => 'Blah::Foo::Bar=HASH(0xdeadbeef)'. (Not such a big win anyway, since internal pointers dump as $VAR1->{blah}.) I could also give a list of interesting keys to dump, which requires another iteration.

(2) I'm using a large library, that I'm only superficially acquainted with, that adds lots of uninteresting data to the objects in many places. It would probably be easier if the library added stuff under a top-level key like 'internal_machinations', where I seldom need to access anything from my code.

(3) There's a shared resource key at many levels, pre-arranged so that $self->{'resource'} points to the same instance, regardless of $self. So in some cases I have to worry about clobbering existing data there, etc.

(4) There are very few accessors in the large library, and only for specific, often-used attributes.

Quantum Mechanics: The dreams stuff is made of

Replies are listed 'Best First'.
Re^3: Object Browser for Perl?
by rjt (Deacon) on Jul 09, 2013 at 00:24 UTC

    ++ and thanks for the additional details, QM. It sounds like Data::Dump (and Data::Dump::Filtered) will do what you want, if you give it a bit of help. Here's a documented example that should get you going:

    Full example source


    Before: ---------------------------------------------------------------------- +------ do { my $a = bless({ attr1 => "val1", circular_ref => 'fix', however => { this => { unwanted => bless({ is => "actually wa +nted" }, "Unwanted") }, }, internal_ref => 'fix', resource => bless({ 1 => 2, 11 => 12, 13 => 14, 15 => 16, 17 => 18, 19 => 20, 3 => 4, 5 => 6, 7 => 8, 9 => 10, note => "Defined outside \$hairy_object", }, "Singleton::Resource"), Silly => { complex => { references => "can be mangled", so +=> "they make more sense." }, }, unwanted => bless({ thing => "We want to ignore" }, "Unwanted" +), }, "Hairy::Object"); $a->{circular_ref} = $a; $a->{internal_ref} = $a->{however}{this}; $a; } After: ---------------------------------------------------------------------- +------ $a = bless( { attr1 => "val1", circular_ref => 'fix', however => # Here, there be dragons { this => { unwanted => bless({ is => "actually wanted" }, "Unwant +ed") }, }, internal_ref => 'fix', resource => $singleton, Silly => "references can be mangled so they make more sense.", }, "Hairy::Object"); $a->{circular_ref} = $a; $a->{internal_ref} = $a->{however}{this};
      ++ Thank you for taking the time to write up a great example!

      Seriously, this is why I love Seekers of Perl Wisdom, for such timely, clear, and precise responses.

      Quantum Mechanics: The dreams stuff is made of

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1043125]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2018-05-28 06:05 GMT
Find Nodes?
    Voting Booth?