导出/打印 Perl AppConfig 值
我正在使用 Perl 和 PHP 解析单个配置文件,并且我想绝对确保它们得到完全相同的结果。因此,我想将解析的配置导出到另一个文件,或者(最好)只是打印它(按字母顺序按键排序)。有没有一些简单的方法可以做到这一点,而不会对 $config->varlist(".")
或 $config->_dump()
结果进行一些丑陋的解析?它们都包含垃圾,例如 hash()
键、一些名为 1
的键以及 AppConfig 配置选项的值(例如 PEDATIC
)。
I'm parsing a single configuration file with both Perl and PHP, and I want to make absolutely sure that they get exactly the same result. Therefore I'd like to either export the parsed configuration to another file or (preferably) just print it (sorted alphabetically by key). Is there some simple way to do this without some ugly parsing of the $config->varlist(".")
or $config->_dump()
results? These both contain junk like hash()
keys, some key called 1
and the values of the AppConfig configuration options like PEDANTIC
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最终得到以下适用于严格、警告和污点模式的代码:
Ended up with the following code which works with strict, warning and taint mode: