[英]MooseX using Config::Std
I'm trying to read a config file with the format 我正在尝试读取具有以下格式的配置文件
<tag>:<value>
but I'm having no luck with any of the modules mentioned in this Stack Overflow question , as the Moose modules referred all seem to favour the config.ini style 但是我对这个Stack Overflow问题中提到的任何模块都不满意 ,因为Moose模块引用的所有模块似乎都偏爱config.ini样式。
<tag>=<value>
which I can't use because I've already got a lot of config files with the :
notation. 我无法使用它,因为我已经有很多带有:
表示法的配置文件。
Can I override the method in MooseX::Configuration
which uses Config::INI::Reader
by a method which uses Config::Std
in an easily maintainable way? 我可以通过使用Config::Std
的方法以易于维护的方式覆盖使用Config::INI::Reader
的MooseX::Configuration
中的方法吗?
It looks to me like you can use MooseX::ConfigFromFile
and implement the get_config_from_file
method like this 在我看来,您可以使用MooseX::ConfigFromFile
并实现这样的get_config_from_file
方法
sub get_config_from_file {
my ($class, $file) = @_;
open my $fh, '<', $file or die $!;
scalar { map { chomp; split /:/, $_, 2 } <$fh> };
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.