in reply to Re: Defining a function in the caller's package
in thread Defining a function in the caller's package

caller always returns the package where the code was, regardless of which name in which package you used to call the code.

I see, this explains why my first attempt had to fail.

Actually, the reference you gave was very helpful, because what my do_something *really* does, is to call NEXT(). I just left out this detail because I thought it would not be relevant to the problem.

I just wonder whether fiddling around with __ANON__, as shown in the example you refered to, is considered portable Perl style (I couldn't find any "official" Perl documentation about __ANON__), or whether the eval solution I used would be better. Both seem to be a hack, but which one is the kinder hack ?-)

-- 
Ronald Fischer <ynnor@mm.st>

Replies are listed 'Best First'.
Re^3: Defining a function in the caller's package
by chromatic (Archbishop) on Aug 08, 2008 at 18:21 UTC

    t/op/caller.t and t/comp/package.t in the core test suite both test aspects of __ANON__'s behavior. I consider that official enough to believe that it won't go away.