简体   繁体   English

使用Config :: Std的MooseX

[英]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::ReaderMooseX::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.

相关问题 在静默模式下使用perl MooseX扩展? - Using the perl MooseX extention in silent mode? 在启动期间主要遇到使用MooseX :: Declare会影响性能吗? - Is the performance hit with using MooseX::Declare mainly encountered during startup? 使用MooseX :: Declare创建BUILDARGS方法的正确方法是什么? - What’s the proper way to create a BUILDARGS method using MooseX::Declare? 我可以使用MooseX :: Declare定义类外的函数吗? - Can I define functions outside of a class using MooseX::Declare? 是否可以使用Moose / MooseX :: Declare for Perl自动强制传递给委托方法的参数(来自Array特征)? - Is it possible to automatically coerce parameters passed to delegated methods (from the Array trait) using Moose/MooseX::Declare for Perl? MooseX :: AttributeHelpers和MooseX :: FollowPBP是否正确交互? - Do MooseX::AttributeHelpers and MooseX::FollowPBP interact correctly? 是MooseX :: Declare和MooseX :: Method ::签名生产准备好了吗? - Are MooseX::Declare and MooseX::Method::Signatures production ready? 如何使用MooseX :: Storage使用自定义init_arg序列化[required]属性? - How to serialize a [required] attribute with a custom init_arg using MooseX::Storage? Perl MooseX ::声明方法属性MooseX :: MethodAttributes - Perl MooseX::Declare with method attributes MooseX::MethodAttributes MooseX ::类型强制和$ self - MooseX::Types coercions and $self
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM