If your project got objects that use the following methods names:
-
to_string(), -
as_string(), -
stringify(),
... Data::Printer might not behave as expected... It will dump the "stringified" object (as defined in your own code, possibly $self->name or something slightly more complicated).
It's possible to disable that feature on p() call:
p $fancy_object, class => { stringify => 0 };
But honestly, that's too much typing verbosity. I prefer, to have a ~/.dataprinter file containing the following:
class.stringify = 0
It's very convenient, for example, to automate the creation of this file in development environment (e.g. Docker containers). I usually add the following to my Dockerfiles :
RUN echo 'class.stringify = 0' > ~/.dataprinter
References
From Data::Printer perldoc:
Finally, if your object implements string overload or provides a method called "to_string", "as_string" or "stringify", Data::Printer will use it. To disable this behaviour, set
class.stringify = 0on your.dataprinterfile, or callp()withclass => { stringify => 0 }.
Top comments (0)