Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

use vs. require in modules
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.


Report this thread to moderator Post Follow-up to this message
Old Post
Christopher J. Bottaro
08-04-04 08:56 PM


Re: use vs. require in modules
>>>>> "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
!

Report this thread to moderator Post Follow-up to this message
Old Post
Randal L. Schwartz
08-04-04 08:56 PM


Re: use vs. require in modules
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.
>



Report this thread to moderator Post Follow-up to this message
Old Post
Christopher J. Bottaro
08-05-04 01:55 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL Beginners archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:35 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.