[Israel.pm] object oriented anonymous autoloading?

Yuval Kogman nothingmuch at woobling.org
Mon Oct 13 13:47:31 PDT 2008


On Mon, Oct 13, 2008 at 15:04:29 +0200, Shmuel Fomberg wrote:
> Hi.
> 
> Gabor Szabo wrote:
> > What you are looking for is to overload the stringification method of
> > your object.
> 
> I can overload the stringification of an object? I didn't know.
> Hmmm.. what evil things I can do with this new toy.... :-)

very evil. behave!

Note that one of the biggest criticisms of Class::DBI is that
stringification made it very confusing to find out if you really
have an object.

An important tip is that you can use overload::StrVal() to avoid
overloading temporarily. Scalar::Util::refaddr is also useful, and
Tie::RefHash and Hash::Util::FieldHash can be used to properly key
by object without the stringified values getting in the way.

-- 
  Yuval Kogman <nothingmuch at woobling.org>
http://nothingmuch.woobling.org  0xEBD27418




More information about the Perl mailing list