加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

perl6 – 模块名称匹配

发布时间:2020-12-15 22:06:28 所属栏目:大数据 来源:网络整理
导读:我有一个模块名称列表,作为Strs,从META6.json中提取.具体来说,依赖于数组.其中包含以下条目: "Config::Parser::toml:ver1.0.1+","Config:api1:ver1.3.5+","Dist::Helper:ver0.21.0+","Hash::Merge","Terminal::Getpass:ver0.0.5+", 我怎样才能最好地匹配个
我有一个模块名称列表,作为Strs,从META6.json中提取.具体来说,依赖于数组.其中包含以下条目:
"Config::Parser::toml:ver<1.0.1+>","Config:api<1>:ver<1.3.5+>","Dist::Helper:ver<0.21.0+>","Hash::Merge","Terminal::Getpass:ver<0.0.5+>",

我怎样才能最好地匹配个别条目?执行eq字符串匹配不够具体,因为Config与Config不匹配:api< 1>:ver< 1.3.5>作为一个字符串.试图匹配使用.starts-with也无法正常工作,如Config:ver< 1.3.5>将不匹配Config:api< 1>:ver< 1.3.5>.

解决方法

use Zef::Distribution::DependencySpecification;

my $spec-ver-all     = Zef::Distribution::DependencySpecification.new("Foo::Bar");
my $spec-ver-zero    = Zef::Distribution::DependencySpecification.new("Foo::Bar:ver<0>");
my $spec-ver-one     = Zef::Distribution::DependencySpecification.new("Foo::Bar:ver<1>");
my $spec-ver-oneplus = Zef::Distribution::DependencySpecification.new("Foo::Bar:ver<1+>");
my $spec-ver-two     = Zef::Distribution::DependencySpecification.new("Foo::Bar:ver<2>");
my $spec-ver-three   = Zef::Distribution::DependencySpecification.new("Foo::Bar:ver<3>");

say $spec-ver-one.spec-matcher($spec-ver-all);         # True
say $spec-ver-one.spec-matcher($spec-ver-two);         # False
say $spec-ver-zero.spec-matcher($spec-ver-oneplus);    # False
say $spec-ver-oneplus.spec-matcher($spec-ver-oneplus); # True
say $spec-ver-three.spec-matcher($spec-ver-oneplus);   # True

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读