in reply to A caller() by any other name

I'm confused - if I understand your question, caller already does what you want: caller.

Update:: Upon reread, do you mean identification of package/object in call? That's already in there with the passed parent object -> perltoot/perltooc covers similar concepts in identifying whether a method is called by an object or a class.

I'm probably just missing the boat on all this.

Replies are listed 'Best First'.
Re^2: A caller() by any other name
by Bloodnok (Vicar) on Dec 02, 2008 at 11:49 UTC
    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 :-))

      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.