On Mon, 24 Sep 2001, Selector, Lev Y wrote:
> This was really elegant.
Thanks. =) I rather liked the result myself.
> my $ss = ${(caller 0)[3]};
> # caler with a parameter in list context
> # returns the list, 4th element of which is the
> # name of the caller subroutine
There's a further trick here -- (caller 0)[3] equals the name of the
subroutine being called, which is "UNIVERSAL::AUTOLOAD". Using that as
a symref, the routine returns the value of $UNIVERSAL::AUTOLOAD, which
in turn contains the name of the method it's supposed to autoload.
This name, of course, then gets treated as the name of a package, and
another method is called on it, and so on...
So this code isn't "use strict" clean. It does, however, run without
any extra output even with warnings enabled.
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
"TIMTOWTDI often means there is more than one really bad way to do it."
-- after Tim Cuffel in comp.lang.perl.misc