Assuming the code like this:
the printout will contain somewhere something likeuse Data::Dumper; my $hashref={ ...., k1 => { .... k2 => { .... kN => {...., mydata => MyClass->new(), .... }}}}; print(Dumper($hashref));
I'm looking for a way to get $hashref pretty-printed, so that the result looks like this:.... mydata => bless(..., 'MyClass') ....
Note that the original hash should not be changed, and I don't know at compile time, where the mydata key is buried inside the hash. I even don't know whether it's name really is 'mydata'. I only know that somewhere in the hash are some data of type MyClass, and these are the ones where I want to take control on how they are pretty printed..... mydata => 'MyOwnRepresentation of the MyClass instance' ....
My first idea was to set
and handle everythin in myfreezer, but as far I can see, a freeze function can only change the internals to the object to be frozen. Is it possible to find a way (without writing a new pretty-printer from scratch)?sub MyClass::myfreezer { ... } $Data::Dumper::Freeze='myfreezer'
I also had a look at Data::Dumper::Streamer, which seems to have a more flexible "Freeze", but still I don't see how this can be achieved.
In reply to Fine grain control over Data::Dumper by rovf
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |