Re: How to write a "caller-inspecting" module?

Re: How to write a "caller-inspecting" module?

am 17.12.2007 20:59:53 von brian d foy

In article , kj
wrote:

> Is it possible to write a module Foo such that if one wrote
>
> package Bar;
> use Foo;
>
> # rest of Bar defined here
>
> sub last_sub_in_Bar { do_something() }
>
> last_top_level_statement_in_Bar();
>
> # suitable moment!
>
> 1; # end of Bar
>
> then, at some *suitable moment* Foo would automatically inspect
> the Bar package (the "caller")

Well, you can always use the caller() built-in to inspect the call
stack and decide what to do. You might also want to look at things such
as Hook::LexWrap for ideas.

If you need more help, give a concrete example about what you are doing
and what you are trying to accomplish.

Good luck,