Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I have a code in Insert::Foo which is meant to run in each requirer's package:
# Insert/Foo.pm our $foo = 1; 1; # Client1.pm package Client1; require Insert::Foo; # $Client1::foo is set by Insert::Foo ... 1; # Client2.pm package Client2; require Insert::Foo; # $Client2::foo is set by Insert::Foo ... 1;
However, if I load Client2 and then Client3, Insert::Foo is not require'd again in Client3, because all modules are only loaded once. I can use do() instead of require(), but then I have to deal with filenames. I can manipulate %INC, but it feels hackish. Surely there's a proper mechanism for doing something like this?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Require into package
by Anonymous Monk on Jan 21, 2011 at 03:31 UTC | |
|
Re: Require into package
by tospo (Hermit) on Jan 21, 2011 at 14:47 UTC | |
|
Re: Require into package
by nif (Sexton) on Jan 21, 2011 at 14:33 UTC |