K
kj
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") and do something (e.g. add some
methods to Bar) on the basis of this inspection. The "suitable
moment" I'm referring to is right after last_sub_in_Bar has been
defined and "last_top_level_statement_in_Bar();" has been executed.
After playing around endlessly with CHECKs and INITs, I still have
not come up with a solution to this problem. The closest to a
solution I can come up with is to move the "use Foo" statement to
right after last_top_level_statement_in_Bar().
Is what I'm trying to do possible?
TIA!
kj
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") and do something (e.g. add some
methods to Bar) on the basis of this inspection. The "suitable
moment" I'm referring to is right after last_sub_in_Bar has been
defined and "last_top_level_statement_in_Bar();" has been executed.
After playing around endlessly with CHECKs and INITs, I still have
not come up with a solution to this problem. The closest to a
solution I can come up with is to move the "use Foo" statement to
right after last_top_level_statement_in_Bar().
Is what I'm trying to do possible?
TIA!
kj