我有以下脚本,它与文档概要段落中的示例几乎相同。
use strict;
use warnings;
use Term::ReadLine;
my $term = Term::ReadLine->new('My shell');
print $term, "\n";
my $prompt = "-> ";
while ( defined ($_ = $term->readline($prompt)) ) {
print $_, "\n";
$term->addhistory($_);
}
它执行没有错误,但不幸的是,即使我单击向上箭头,我也只会得到^[[A
并且没有历史记录。我错过了什么?
声明print $term
打印。Term::ReadLine::Stub=ARRAY(0x223d2b8)
由于我们在这里,我注意到它打印了带下划线的提示......但我在文档中找不到任何可能阻止它的东西。有什么办法可以避免吗?