Excepting that Module must be a bareword, use is exactly equivalent to
Now, require is a run-time compilation and use is a compile-time compilation. I've often done something along the lines ofBEGIN { require Module; import Module LIST; }
With appropriate checks on $var, of course!my $moduleName = "Foo::Bar::$var"; require $moduleName;
The real question arises as to whether or not OO Perl should be doing anything with import(). I would say that it shouldn't be, because import() would seem to violate encapsulation. Instead, require would seem to be indicated. And, if all your requires are on top, then it's almost as if you're doing it at compile-time, because they're the first things to be run.
------
We are the carpenters and bricklayers of the Information Age.
Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Is use really appropriate in a OO system?
by merlyn (Sage) on Sep 25, 2001 at 20:18 UTC | |
|
Re: Is use really appropriate in a OO system?
by princepawn (Parson) on Sep 25, 2001 at 20:07 UTC | |
|
Re: Is use really appropriate in a OO system?
by chromatic (Archbishop) on Sep 25, 2001 at 23:59 UTC | |
|
Using/abusing import
by runrig (Abbot) on Sep 25, 2001 at 20:31 UTC |