- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
编辑:使用 sudo cpanm Data::Match --force
我正在尝试使用 ubuntu 18.04 安装“Data::Match”perl 模块。我使用:
perl Makefile.pl
make
make test
我收到以下错误:
make test
PERL_DL_NONLAZY=1 "/usr/bin/perl" "-Iblib/lib" "-Iblib/arch" test.pl
1..1
# Running under perl version 5.026001 for linux
# Current time local: Wed Jun 29 18:41:13 2022
# Current time GMT: Wed Jun 29 15:41:13 2022
# Using Test.pm version 1.30
Can't use an array as a reference at blib/lib/Data/Match.pm line 968.
Compilation failed in require at test.pl line 10.
BEGIN failed--compilation aborted at test.pl line 10.
Makefile:825: recipe for target 'test_dynamic' failed
make: *** [test_dynamic] Error 255
我安装了许多其他模块,它们都运行良好。我也尝试安装
perl -MCPAN -e shell
但这并没有帮助。
我该怎么办?
最佳答案
Data::Match
模块有一些 Perl v5.22 收紧的语法。这就是它失败的原因。请注意,强制安装具有此类严重问题的模块意味着它只会在您运行程序时失败。
如果可以,请不要使用此模块。我不知道它的作用,所以我没有任何替代建议。
假设您出于某种原因需要此模块,即使它已有 20 年历史。也许您正在支持一个您只需要开始工作的旧版应用程序。
这一行 ( L968 ) 取消引用本身就是数组引用的数组元素:
$str .= $sep . '{' . join(',', @$ind->[0]) . '}';
这应该是分隔引用部分的circumfix符号:
$str .= $sep . '{' . join(',', @{$ind->[0]}) . '}';
如果您在运行 perl Makefile.PL
之前对 Match.pm 进行了更改,则测试会通过(但会出现警告)并且您可以安装该模块。
如果这就是您所需要的,您可以到此为止。
CPAN.pm 有办法处理这些情况,因此您不必在每次要安装模块时都进行更改。在 CPAN.pm 开始工作之前,它可以修补有问题的发行版、建议替代发行版或许多其他事情。你用“distroprefs”来做到这一点。 CPAN.pm repo中有很多例子.
有几件事需要设置。首先,设置您的 distroprefs 目录 (o conf init prefs_dir
)。其次,配置一个目录来保存你的补丁(o conf patches_dir
)。我在我的 .cpan 目录下选择 patches,但它可以是任何东西。退出前保存更改。
% cpan
% cpan[1]> o conf init prefs_dir
Directory where to store default options/environment/dialogs for
building modules that need some customization? [/Users/brian/.cpan/prefs]
% cpan[2]> o conf patches_dir /Users/brian/.cpan/patches
% cpan[3]> o conf commit
distropref 有两部分。第一个指定你想要发生什么。这可以是 YAML、Storable 或 Data::Dumper 文件。如果是 YAML(大多数人似乎都在使用),那么您需要先安装 YAML
模块。
这是一个简单的 distroprefs 文件。它告诉 CPAN.pm 如何匹配您在 CPAN (AUTHOR/FILE) 上看到的分布。在此示例中,它的操作是 patches
,这是一个补丁文件数组。由于您设置了 patches_dir
,因此它会出现在该位置。补丁的文件名并不特殊,可以压缩。我选择了发行版名称,我的名字作为修补它的人,然后是 .patch。
---
match:
module: "Data::Match"
distribution: "^KSTEPHENS/Data-Match-0.06.tar.gz"
patches:
- Data-Match-0.06-BDFOY-01.patch
这是你的补丁。备份原始文件,更改目标文件,然后获取统一差异(或您的 patch
理解的任何内容):
$ diff -u Match.pm.orig Match.pm
--- Match.pm.orig 2022-06-29 15:04:06.000000000 -0400
+++ Match.pm 2022-06-29 14:55:45.000000000 -0400
@@ -965,7 +965,7 @@
elsif ( $ref eq 'HASH' ) {
if ( ref($ind) eq 'ARRAY' ) {
# Not supported by DRef.
- $str .= $sep . '{' . join(',', @$ind->[0]) . '}';
+ $str .= $sep . '{' . join(',', @{$ind->[0]}) . '}';
} else {
$str .= $sep . $ind;
}
但是你想在你的补丁目录中使用你指定的名称,所以将输出重定向到那里:
$ diff -u Match.pm.orig Match.pm > /Users/brian/.cpan/patches/Data-Match-0.06-BDFOY-01.patch
如果你真的想变得很花哨,你可以把那个补丁目录放在你的配置文件的环境变量中,这样你就不必记住它了:
$ diff -u Match.pm.orig Match.pm > $CPAN_PATCHES_DIR/Data-Match-0.06-BDFOY-01.patch
现在,当您尝试使用 cpan
安装 Data::Match
时,它知道它正在安装 Data-Match-0.06
,它匹配该发行版来自 distroprefs 文件,该 distroprefs 文件告诉 CPAN.pm 执行操作。在这种情况下,它需要找到补丁文件并应用它。打上补丁后,测试通过,安装成功:
% cpan Data::Match
Reading '/Users/brian/.cpan/Metadata'
Database was generated on Wed, 29 Jun 2022 05:56:00 GMT
Running install for module 'Data::Match'
______________________ D i s t r o P r e f s ______________________
Data-Match-0.06-BDFOY-01.yml[0]
Checksum for /Users/brian/.cpan/sources/authors/id/K/KS/KSTEPHENS/Data-Match-0.06.tar.gz ok
Applying 1 patch:
/Users/brian/.cpan/patches/Data-Match-0.06-BDFOY-01.patch
/usr/bin/patch -N --fuzz=3 -p0
patching file Match.pm
Configuring K/KS/KSTEPHENS/Data-Match-0.06.tar.gz with Makefile.PL
Checking if your kit is complete...
Looks good
Generating a Unix-style Makefile
Writing Makefile for Data::Match
Writing MYMETA.yml and MYMETA.json
KSTEPHENS/Data-Match-0.06.tar.gz
/usr/local/perls/perl-5.36.0/bin/perl Makefile.PL -- OK
Running make for K/KS/KSTEPHENS/Data-Match-0.06.tar.gz
cp Match.pm blib/lib/Data/Match.pm
cp lib/Sort/Topological.pm blib/lib/Sort/Topological.pm
Manifying 2 pod documents
KSTEPHENS/Data-Match-0.06.tar.gz
/usr/bin/make -- OK
Running make test for KSTEPHENS/Data-Match-0.06.tar.gz
PERL_DL_NONLAZY=1 "/usr/local/perls/perl-5.36.0/bin/perl" "-Iblib/lib" "-Iblib/arch" test.pl
1..1
# Running under perl version 5.036000 for darwin
# Current time local: Wed Jun 29 15:54:13 2022
# Current time GMT: Wed Jun 29 19:54:13 2022
# Using Test.pm version 1.31
ok 1
PERL_DL_NONLAZY=1 "/usr/local/perls/perl-5.36.0/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/t1.t .. ok
t/t2.t .. ok
t/t3.t .. 1/15 splice() offset past end of array at /Users/brian/.cpan/build/Data-Match-0.06-15/blib/lib/Data/Match.pm line 1941.
t/t3.t .. ok
t/t4.t .. ok
All tests successful.
Files=4, Tests=182, 0 wallclock secs ( 0.03 usr 0.01 sys + 0.18 cusr 0.04 csys = 0.26 CPU)
Result: PASS
关于perl - 安装 perl 模块时不能使用数组作为引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72804459/
如果我的 Perl 程序使用 Perl 模块,它将如何确定在哪里可以找到包含模块代码的文件? 例如,如果程序包含: use MyModule1; # Example 1 us
我在一个文件中有一些不同格式的数字:8.3、0.001、9e-18。我正在寻找一种简单的方法来读取它们并存储它们而不会损失任何精度。这在 AWK 中很容易,但在 Perl 中是如何完成的呢?我只愿意使
我在一个文件中有一些不同格式的数字:8.3、0.001、9e-18。我正在寻找一种简单的方法来读取它们并存储它们而不会损失任何精度。这在 AWK 中很容易,但在 Perl 中是如何完成的呢?我只愿意使
我正在自学 Perl,并且在我的 Windows 8 64 位系统上安装了 Strawberry。 Strawberry 命令行似乎工作正常,我在 C 驱动器上的 Strawberry 文件夹中创建了
我在 Perl 模块 IO::Socket::SSL 中发现了一个错误,我可能会修复它,但是,我担心测试修复。我从 Debian 下载了源码包(因为我打算为它制作一个 Debian 包或补丁)并查看了
我有一个 perl 文件,它使用了两个 perl 模块 A.pm 和 B.pm。 但是在 B.pm 中我需要调用 A.pm 的子程序。即使我在 A.pm 中使用并尝试使用它,我仍然遇到未定义的错误。
有没有办法在 Perl 运行时加载整个模块?我原以为我用 autouse 找到了一个很好的解决方案,但以下代码无法编译: package tryAutouse2; use autouse 'tryAu
过去,我编写过许多 perl 模块,以及不止一些独立的 perl 程序,但我之前从未发布过多文件 perl 程序。 我有一个几乎处于 beta 阶段的 perl 程序,它将被开源发布。它需要一些数据文
我有 1 个 perl 脚本,我们在其中编写了几个子例程。例子: # Try_1.pl main(); sub main{ --- --- check(); } check { -- --} 现在,
似乎 CPAN 上的一些(很多?)模块部分是使用 XS 在 C 中实现的,如果需要,可以回退到纯 perl 实现。虽然这很聪明,但它显然会损害性能,我想知道它是否会发生,以便我可以解决问题。 有没有一
我对 perl 很陌生。我希望我可以从 perl 安装一些软件包,我这样做是这样的: perl -MCPAN -e 'install VM::EC2' 我猜它由于依赖而失败,它显示: Result:
给定一个 Perl 包 Foo.pm,例如 package Foo; use strict; sub bar { # some code here } sub baz { # more
我有一个用 Perl 编写的测试生成器。它生成连接到模拟器的测试。这些测试本身是用 Perl 编写的,并通过其 API 连接到模拟器。我希望生成的代码是人类可读的,这意味着我希望它能够正确缩进和格式化
我正在学习 Perl,非常新的用户。我可以知道这些 Perl 代码之间有什么区别吗? #!/usr/bin/perl & #!/usr/bin/perl -w 最佳答案 那不是 perl 代码,它是
我不认为这是一个重复的问题。这专门针对 Perl 模块附带的脚本。 通常,在安装多个 Perl 版本时,您可以将 perl 可执行文件标记为版本号 (perl5.32),这样它们就可以在 /whate
我有一个在文件中使用 Blowfish 加密的程序和第二个 perl 程序,它提示输入用于将其解密为字符串的密码,我希望不必将解密的源代码写入硬盘驱动器,尽管将它放在内存中并不是真正的问题,因为运行程
有没有人为 Perl 中的惰性求值列表找到了一个好的解决方案?我尝试了很多方法来改变类似的东西 for my $item ( map { ... } @list ) { } 进入懒惰的评估——例如,通
我安装了多个版本的 Perl。 我已经指定了要使用的版本。但是为了验证,我想从 .pl 脚本本身输出 Perl 的版本。 这可能吗? 在 Perl 脚本中解析“perl --version”的输出似乎
人们还经常问“我怎样才能编译 Perl?”而他们真正想要的是创建一个可以在机器上运行的可执行文件,即使他们没有安装 Perl。 我知道有几种解决方案: perl2exe靛蓝之星 它是商业的。我从未尝试
关闭。这个问题是opinion-based .它目前不接受答案。 想改进这个问题?更新问题,以便 editing this post 可以用事实和引用来回答它. 8年前关闭。 Improve this
我是一名优秀的程序员,十分优秀!