Solved

package,module or ???

Posted on 2001-06-14
2
138 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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 …
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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…

738 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