如何启动Perl的交互式控制台,类似于Ruby的irb命令或python的python命令?
当前回答
Matt Trout不仅写了一篇关于REPL的文章,他实际上也写了一篇——Devel::REPL
我曾经使用过它,它工作得相当好,并且正在积极开发中。
顺便说一句,我不知道为什么有人贬低了那个提到从控制台使用“perl -e”的人。这不是一个真正的REPL,但它非常有用,我一直在使用它。
其他回答
你可以在一个简单的程序上使用perl调试器,如下所示:
perl -de1
还有Alexis Sukrieh的Perl控制台应用程序,但我没有使用过它。
你可以在网上做这件事(就像生活中的许多事情一样):
https://www.tutorialspoint.com/execute_perl_online.php
如果需要历史记录,请使用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>
我已经创建了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不像Python那样内置交互式控制台。但是,您可以使用Perl调试器来做调试相关的事情。您可以使用-d选项打开它,但您可能想要查看'man perldebug'以了解它。
在谷歌搜索一下之后,有一个单独的项目实现了Perl控制台,您可以在 Perl控制台- Perl代码与完成的交互式计算器。
希望这能有所帮助!
推荐文章
- Chrome: console.log, console.debug不工作
- 访问控制台和扩展的后台开发工具
- 将Chrome中的console.log保存为文件
- 清除javascript控制台在谷歌Chrome
- 安装缺少的Perl模块最简单的方法是什么?
- 我如何才能快速和所有的数字在一个文件?
- 显示/隐藏c#控制台应用程序的控制台窗口
- 我如何使用布尔变量在Perl?
- 打印对象的所有属性
- 在PowerShell中重新加载路径
- IE8的console.log怎么了?
- 如何将文件加载到python控制台?
- Perl的反撇号、system和exec之间有什么区别?
- Go提供REPL吗?
- 如何包括JavaScript文件或库在Chrome控制台?