我有一个模块名称列表,作为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