我已经在 Perl 中安装了 Expect 模块,位置为 C:\strawberry\perl\lib。
作为先决条件,我首先在安装 perl 的同一位置安装了 IO-Tty 模块。
现在如果我正在做
use Expect;
抛出错误
Can't locate IO/Pty.pm in @INC (@INC contains: C:/strawberry/perl/site/lib C:/st
rawberry/perl/vendor/lib C:/strawberry/perl/lib .) at C:/strawberry/perl/lib/Exp
ect.pm line 22.
BEGIN failed--compilation aborted at C:/strawberry/perl/lib/Expect.pm line 22.
Compilation failed in require at croak.txt line 1.
BEGIN failed--compilation aborted at croak.txt line 1.
可能的原因是
Perl 正在寻找从 Expect.pm 调用的 IO::Pty 和 IO::Tty 模块。但是当我安装了 IO::Tty 模块时,它有 2 个 pm 文件,名称为 Pty.pm 和 Tty.pm
package Expect; use IO::Pty 0.97; # We need make_slave_controlling_terminal() use IO::Tty;
但是 perl 正在寻找 IO::Tty 模块。
这是否导致了问题。如果是的话我该如何前进
最佳答案
Expect 在 Windows 下不起作用。
至少这是我在查看 CPAN Resters 结果时的印象。这张表在这里: http://matrix.cpantesters.org/?dist=Expect;maxver=1 表明 Windows 下的 Expect 从来没有 PASS。
此外,Expect 文档讨论了该模块无法与 ActivePerl 一起使用,并建议改用 cygwin: https://metacpan.org/module/RGIERSIG/Expect-1.21/Expect.pod#Can-I-use-this-module-with-ActivePerl-on-Windows 。 我认为 Expect 也不适用于 StrawberryPerl。
关于perl - Expect 模块无法在 perl 中工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18998270/