Normally, if a package uses some other module, the symbols are only imported for the package's use. With the caller function, a crafty meta-package can emulate the use statements on behalf of the main script. This can make the Library more friendly to use and document.
package Library; ... sub import { my $calling = (caller())[0]; eval qq{ # Load these on behalf of the calling package. package $calling; use Library::This; use Library::That; use Library::TheOther::Thing; }; die $@ if $@; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Meta Module imports several packages
by Aristotle (Chancellor) on May 04, 2003 at 13:54 UTC | |
by halley (Prior) on May 04, 2003 at 16:22 UTC |