如何在Perl中管理配置文件?

如何在Perl中管理配置文件?

问题描述:

我有一个程序必须从PHP脚本读取配置文件,并且快速搜索已经发现有几十种方法来处理Perl中的配置文件:

I have a program that has to read a configuration file from a PHP script, and a quick search has revealed there are dozens of ways to handle configuration files in Perl:

  • Config data in a separate file
  • AppConfig
  • Config::General
  • Config::IniFiles
  • Config::Scoped
  • Config::Simple
  • ConfigReader::Simple
  • And many others

Brian提供概述此处

Brian provides an overview here.

配置:: Simple将为我工作,因为现有的文件是类似INI的。我有兴趣知道他们的代码中经常使用什么风格?

Config::Simple will work for me, since the existing file is INI-like. I am interested to know what style people regularly use in their code though?

我非常喜欢使用 YAML 配置文件。我发现他们是非常可读和容易操纵。它们自然适合Perl,主要构造是Arrays和Hashes。

I quite like using YAML configuration files. I find them to be very readable and easily manipulated. They fit naturally into Perl as well as the primary constructs are Arrays and Hashes.