Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: store module names in an array

by kyle (Abbot)
on Oct 27, 2009 at 03:34 UTC ( #803372=note: print w/replies, xml ) Need Help??


in reply to store module names in an array

You could wrap it in a string eval like so:

for my $dbh ( @dbf ) { die $@ if ! eval "use $dbf; 1"; }

I might be inclined to put the whole thing in a BEGIN block.

BEGIN { my @dbf = ...; for my $dbf ( @dbf ) { require $dbf; $dbf->import(); } }

Either way, there's a big security risk if @dbf comes from an untrusted source, but I think the risk is bigger with eval. It might be useful to read the documentation for use and require to see how close they are to what you want to do.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://803372]
help
Chatterbox?
[MidLifeXis]: Project Admin, a while ago: "No, I would prefer you didn't close that ticket yet confirming $vendor's support process yet. Continue to periodically check back to see if it has changed."...
[MidLifeXis]: Project Admin, today, after many periodic updates from me: "Why hasn't this been closed yet? Is there anything I can do to get this closed?" <facepalm>
[MidLifeXis]: In addition to SOAP (last hour of cb), try water. ;-)

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (11)
As of 2017-01-19 12:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (170 votes). Check out past polls.