Reputation: 4709
I'm looking for a perl config file editor. I see some great mods like:
However, these options tend to load ini, yaml, json, etc.. files instead of perl config files.
Wouldn't it always be faster and safer in perl to load a perl config file? That way the file is loaded through an eval or do instead of parsed manually through reg exps etc. However I can't seem to find a good prewritten version of this.
Reading and Writing Perl... - old perlmonks thread
OpenPlugin::Config::Perl - potentially what i'm looking for ??
What is the best module to use? Is there a reason ini file loading seems to be more popular than loading a file directly in the language it is already written in?
Thanks
UPDATE
I would not be evaluating a random file, I will be loading my own custom perl file. This would be the same thing as loading a php config file already written in php. Anyone know of a module that uses PERL?
Upvotes: 1
Views: 920
Reputation: 1316
I don't think Config::Any provides Read+Write.
But if you are willing to work with Perl Data Structure for config as there are some arguments against JSON etc - you may want ot take a look at Config::Perl
Upvotes: 0
Reputation: 3460
Unless we're talking about gigantic config files, I wouldn't worry about the speed of loading and parsing a config file.
Regarding safety, you wouldn't want to just eval
any old Perl code / config that you'd read from the filesystem - who knows what it will try to do? You'd want to make sure to use the reval
method from the Safe module.
Upvotes: 3
Reputation: 8926
eval
ing a random config file as Perl is fraught with danger. It could have anything in it, including code to wipe your hard drive. It also weakens locality of reference because you have executable code that's affecting the overall state of your program outside your program.
For configuration files, I often use XML::Simple. It's an easy way of getting basic name-value pairs.
Upvotes: 0
Reputation: 86
The project I'm working on at the moment uses Config::Any. It's fairly easy to use and is very flexible with which types of config files that it will accept (On the synopsis it says it uses yaml, json, ini, among other ones).
In my experience using JSON or yaml seems to do the trick but I'm not well versed in the pros and cons of using each one so you'll have to decide that for yourself :). Hope that helped ^^
Upvotes: 0