[Israel.pm] how to intercept module calls
Gaal Yahas
gaal at forum2.org
Sun Oct 8 22:22:42 EEST 2006
On Sun, Oct 08, 2006 at 09:03:23PM +0200, Yuval Kogman wrote:
> > {
> > no strict;
> > @subs = grep { defined *{$pkg . "::$_"} } keys %{$pgk . "::"};
> > }
>
> err, that should be &{$pkg . "::$_"} or maybe *{$pkg . "::$_"}{CODE}
Oops, indeed. Copy malfunction. (I meant the latter. How could I not
prefer the syntax that the documentation "lovingly" calls "*foo{THING}"?)
> > A .pm file can declare more than one package, and indeed can install code
> > in arbitrary other packages as well. I don't know of a good response to
> > the second of these problems.
>
> You can copy the entire symbol table to another hash before and
> after loading the module, and then diff it using Data::Compare or
> even have a convenient hook called via Hash::Merge.
Two other things to consider: AUTOLOAD and wrappings/overrides that the
target module might itself perform.
--
Gaal Yahas <gaal at forum2.org>
http://gaal.livejournal.com/
More information about the Perl
mailing list