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


当前回答

Perl不像Python那样内置交互式控制台。但是,您可以使用Perl调试器来做调试相关的事情。您可以使用-d选项打开它,但您可能想要查看'man perldebug'以了解它。

在谷歌搜索一下之后,有一个单独的项目实现了Perl控制台,您可以在 Perl控制台- Perl代码与完成的交互式计算器。

希望这能有所帮助!

其他回答

Sepia和PDE也有自己的reps(用于GNU Emacs)。

我已经创建了perli,一个运行在Linux、macOS和Windows上的Perl REPL。

它的重点是自动打印结果,方便的文档查找,并且简单 检查正则表达式匹配。 你可以在这里看到截图。

它可以独立工作(除了Perl本身,没有其他依赖项),但是强烈建议安装rlwrap,以便支持命令行编辑、持久的命令历史记录和制表符补全——在这里阅读更多信息。

安装

If you happen to have Node.js installed: npm install -g perli Otherwise: Unix-like platforms: Download this script as perli to a folder in your system's path and make it executable with chmod +x. Windows: Download the this script as perli.pl (note the .pl extension) to a folder in your system's path. If you don't mind invoking Perli as perli.pl, you're all set. Otherwise, create a batch file named perli.cmd in the same folder with the following content: @%~dpn.pl %*; this enables invocation as just perli.

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

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

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

有两种流行的Perl repl。

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

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

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

Perl -d是你的朋友:

% perl -de 0