Where is Perl's default object-to-string conversion defined?

Viewed 1136

If I print a reference to a blessed object in Perl, I get something like this:

Foo::Bar=HASH(0x0123456789ab)

Where is that code defined? The first part is ref($obj), but where does the HASH hex value come from?

I'm attempting to write a to_string overloaded operator for objects that have an optional name attribute. If the name is provided, I'd like it to print

Foo::Bar(name=joe)

and fall back to the default Perl string if not name is undefined. So I either have to be able to invoke Perl's conversion code from my code, or write the equivalent myself, hence my question.

3 Answers
Related