Syntactic Confectionery Delight | |
PerlMonks |
Re: require & import $module_nameby tobyink (Canon) |
on Jul 19, 2012 at 19:45 UTC ( [id://982705]=note: print w/replies, xml ) | Need Help?? |
eval "use $module" is pretty simple if you're 100% confident that the $module variable contains a safe package name. (You want to be sure that it doesn't contain something like "strict; system('rm -fr /home')"!) Module::Runtime and Class::Load provide somewhat safer techniques if you're less sure about the contents of the variable (e.g. the variable came from the outside world).
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
In Section
Seekers of Perl Wisdom
|
|