Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Passing package/module names to script as argument

by Eily (Monsignor)
on Sep 13, 2018 at 12:57 UTC ( [id://1222282]=note: print w/replies, xml ) Need Help??


in reply to Passing package/module names to script as argument

push(@objects, $_->new()) foreach ("greenObjects", "redObjects"); already does (mostly) the same as push(@objects, greenObjects->new()); push(@objects, redObjects->new()); so this only leaves the use statements. It looks like Module::Load does what you want without needing to call eval.

autoload $_ and push(@objects, $_->new()) foreach @ARGV;

Edit: Module::Load accepts an arbitrary path though, so you might have to check the input for security.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-26 00:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found