
fashimpaur
User
/ Moderator
Jun 20, 2002, 9:11 AM
Post #1 of 4
(2678 views)
|
Dynamic Perl Module Loading
|
Can't Post
|
|
Is there any way to dynamically, or better yet, selectively, load perl modules? Example: I have an application which runs from either a web server or from the command line. What I would like to do: use strict; use someOtherPackage; if (defined $ENV{'HTTP_USER_AGENT'}){ use CGI; use CGI::Pretty; use CGI::Carp 'fatalsToBrowser'; } # ... logic for command line and browser interfaces However, when I do this, if a fatal error occurs when running it from the command line, all errors are displayed with HTML tags invoked by CGI::Carp. So, therefore, all modules are getting loaded even though I requested them to be used only if there is an HTTP_USER_AGENT. Is there a way to do only load the modules if they are truly required? Any assistance would be greatly appreciated. Dennis $a="c323745335d3221214b364d545". "a362532582521254c3640504c3729". "2f493759214b3635554c3040606a0", print unpack"u*",pack "h*",$a,"\n\n";
|