in reply to Re^2: What's the best way to put perl code in config file?
in thread What's the best way to put perl code in config file?

If you can trust your users (or if you can trust them to secure their machines properly), a clean way to do this is to let your application have a "plugins" directory full of simple Perl modules all adhering to a common interface, and then require each of these modules. Each plugin module could have a method called "make_callback" (or equivalent), and they would be all properly namespaced and sorted.

Then you will need some way to instantiate them and add them to a list of active plugins, but this should be left as an exercise to the reader (it's simple enough).

But in general, unless you are writing something like the GIMP or PhotoShop or an Application Server, it might be best to not have users write code to modify the way your program works. Depends what you are doing, of course, there may be moer usable/friendly ways. Meanwhile, if I'm installing a Wiki or something, I have no problem editing perl config files, it's just horrific if you mess one up because you'd get a syntax error or some obscure runtime error rather than the application telling you what's up as part of a config file verification process. So avoid making users write code if you can help it (some don't even know what '$' means!)

  • Comment on Re^3: What's the best way to put perl code in config file?