Solved

package,module or ???

Posted on 2001-06-14
2
137 Views
Last Modified: 2010-03-05
Hi Experts,

My question is somewhat difficult to explain, but i'll try anyway :)

I'm working on this cgi application in Perl where an administrator can activate and deactivate certain parts of the application.
There's is a lot of different parts that can be activated or deactivated. My problem is i don't quite know how to implement this the most efficient way.

Should i write all the parts as functions in a package that would be required in the top of my cgi script? The problem with this, as I see it, is that my application would include all the code of the different parts even though they are not needed( if they are deactivated ).

Should I put all the parts in a module?
Should I put each part in it's own module?

Is it possible to somehow only include something in your code if it is needed? ie:
if( module1IsActivated) use module 1;

Or maybe i should do this in a completely different way that i haven't thought of :)

Any ideas appreciated!
0
Comment
Question by:psogaa
2 Comments
 
LVL 5

Accepted Solution

by:
marecs earned 200 total points
ID: 6190111
Including code only as it is needed sounds efficient enough. The require keyword only loads a module when it is encountered, rather than the use keyword that loads modules at compile time.

So
if (module1IsActivated) {
   require module1;
}

should work, whereas

if (module1IsActivated) {
   use module1;
}

will gain you nothing because the module is loaded at startup anyway.
0
 
LVL 2

Author Comment

by:psogaa
ID: 6190231
Cool, thanks :)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question