in reply to Re: A caller() by any other name
in thread A caller() by any other name

Sadly, caller doesn't quite do what I want :-( Hence my question.

As you say, when called from a class method/package sub, (caller)[0] returns the package name. Whereas what I'm suggesting it could return is an object reference e.g. <pkg>=HASH(0x123456) when the caller is an object.

Hope that makes it clearer.

A user level that continues to overstate my experience :-))

Replies are listed 'Best First'.
Re^3: A caller() by any other name
by kennethk (Abbot) on Dec 02, 2008 at 18:00 UTC

    Hope you are still checking the thread. Having read your comments and those that followed, I think I grok what you are getting at. Assuming you are not threading your code, you could essentially add a line at the start of every subroutine that caches the class/object reference of the call in a package global. You could then use caller to id the package, and the local variable to id what the last object used was. Clearly not elegant, and a horrible violation of OO ideals, but would work and shouldn't be too rough to create.