Home > Archive > PERL Beginners > August 2004 > use vs. require in modules
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
use vs. require in modules
|
|
| Christopher J. Bottaro 2004-08-04, 3:56 pm |
| i have 4 packages:
PackageA
use IO::File;
require My::Utils::Reader
PackageB
use IO::File;
use XML::Writer;
My::Utils::Reader
use My::Utils;
My::Utils
use Exporter;
in my perl program, i dynamically load PackageA and PackageB like this:
eval("require $package_name1");
eval("require $package_name2");
my question is why does PackageA have to "require My::Utils::Reader" instead
of "use My::Utils::Reader"? PackageB dynamically loads fine and it "uses"
other packages. in fact, every package i list here uses "use" instead of
require. why is there an exception for PackageA and "require
My::Utils::Reader"?
thanks for the help.
| |
| Randal L. Schwartz 2004-08-04, 3:56 pm |
| >>>>> "Christopher" == Christopher J Bottaro <cjbottaro@alumni.cs.utexas.edu> writes:
Christopher> My::Utils
Christopher> use Exporter;
Do you have "@ISA = Exporter" too? Much easier to write this as
use base 'Exporter';
This might be why it needs to be require'd instead of use'd.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
| |
| Christopher J. Bottaro 2004-08-04, 8:55 pm |
| heh, that was it, thanks a bunch.
Randal L. Schwartz wrote:
>
> Christopher> My::Utils
> Christopher> use Exporter;
>
> Do you have "@ISA = Exporter" too? Much easier to write this as
>
> use base 'Exporter';
>
> This might be why it needs to be require'd instead of use'd.
>
|
|
|
|
|