Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Most effective way to dynamically load a module?

by jbrugger (Parson)
on Aug 22, 2006 at 05:04 UTC ( #568765=note: print w/ replies, xml ) Need Help??


in reply to Most effective way to dynamically load a module?

Eval works ok, but you're using the 'quote' version here, so i'd do a

if ($class !~ /^[a-z0-9_]*$/i) { print $cgi->header(); print "<h1> You tried something that's not allowed! </h1><br>< +br>"; exit(); }
before using the eval statement.
Alternative you'd be able to use:
eval { require $class . ".pm"; }; if ($@) { print $cgi->header(); print "$@"; print "<h1> The class '$class' does not exist! </h1><b +r><br>"; } else { # Do your stuff. $class->main($cgi,$user); }
"We all agree on the necessity of compromise. We just can't agree on when it's necessary to compromise." - Larry Wall.


Comment on Re: Most effective way to dynamically load a module?
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://568765]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (7)
As of 2015-07-30 11:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (271 votes), past polls