Solved

package,module or ???

Posted on 2001-06-14
2
133 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now