如何启动Perl的交互式控制台,类似于Ruby的irb命令或python的python命令?


当前回答

Perl没有控制台,但是调试器可以作为控制台使用。在命令提示符下,键入perl -de 1。(值“1”无关紧要,它只是一个没有任何作用的有效语句。)

Perl shell也有几个选项: 存档的“perlfaq3”页面,其中包含问题“有Perl Shell吗?”

有关更多信息,请阅读perlfaq3(当前版本)。

其他回答

Perl -d是你的朋友:

% perl -de 0

re.pl来自Devel::REPL

您可以直接进入内置调试器并从那里运行命令。

   perl -d -e 1

在 Debian/Ubuntu 下:

$ sudo apt-get install libdevel-repl-perl
$ re.pl

$ sudo apt-get install libapp-repl-perl
$ iperl

如果需要历史记录,请使用rlwrap。这可以是你的~/bin/ips,例如:

#!/bin/sh
echo 'This is Interactive Perl shell'
rlwrap -A -pgreen -S"perl> " perl -wnE'say eval()//$@'

这是它的样子:

$ ips
This is Interactive Perl shell
perl> 2**128
3.40282366920938e+38
perl>