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


当前回答

Read-eval-print循环:

$ perl -e'while(<>){print eval,"\n"}'

其他回答

还可以在CPAN上查找ptkdb: http://search.cpan.org/search?query=ptkdb&mode=all

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

   perl -d -e 1

有两种流行的Perl repl。

Devel: REPL很棒。 但在我看来,回复更好。

对于回复,只需运行它作为一个命令。模块安装应答脚本。如果您已经安装了模块,但没有该命令,请检查PATH变量。

$ reply --help
reply [-lb] [-I dir] [-M mod] [--version] [--help] [--cfg file]

如果需要历史记录,请使用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> 

re.pl来自Devel::REPL