Solved

package,module or ???

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
delete query using perl dbi 3 96
Perl output collect 7 65
crawling gofundme 4 121
stftime format 4 55
On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
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…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

861 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

20 Experts available now in Live!

Get 1:1 Help Now