如何为Perl启动交互式控制台?

时间:2021-09-01 20:44:58

How can I start an interactive console for Perl, similar to the irb command for Ruby or python for Python?

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

22 个解决方案

#1


246  

You can use the perl debugger on a trivial program, like so:

您可以在一个普通的程序上使用perl调试器,如下所示:

perl -de1

Alternatively there's Alexis Sukrieh's Perl Console application, but I haven't used it.

或者有Alexis Sukrieh的Perl控制台应用程序,但是我还没有使用它。

#2


52  

Not only did Matt Trout write an article about a REPL, he actually wrote one - Devel::REPL

马特·特劳特不仅写了一篇关于回购的文章,他实际上还写了一篇——回购:回购

I've used it a bit and it works fairly well, and it's under active development.

我使用了它,它运行得相当好,并且在积极的开发中。

BTW, I have no idea why someone modded down the person who mentioned using "perl -e" from the console. This isn't really a REPL, true, but it's fantastically useful, and I use it all the time.

顺便说一下,我不知道为什么有人会把使用“perl -e”的人从控制台调下来。这不是真的回购,是真的,但它非常有用,我一直在用它。

#3


33  

I wrote a script I call "psh":

我写了一个我称之为“psh”的剧本:

#! /usr/bin/perl

while (<>) {
  chomp;
  my $result = eval;
  print "$_ = $result\n";
}

Whatever you type in, it evaluates in Perl:

无论您输入什么,它都用Perl进行计算:

> gmtime(2**30)
gmtime(2**30) = Sat Jan 10 13:37:04 2004

> $x = 'foo'
$x = 'foo' = foo

> $x =~ s/o/a/g
$x =~ s/o/a/g = 2

> $x
$x = faa

#4


19  

I think you're asking about a REPL (Read, Evaluate, Print, Loop) interface to perl. There are a few ways to do this:

我认为您是在询问perl的REPL(读取、评估、打印、循环)接口。有几种方法可以做到这一点:

  • Matt Trout has an article that describes how to write one
  • Matt Trout有一篇文章描述了如何写
  • Adriano Ferreira has described some options
  • 阿德里亚诺·费雷拉描述了一些选择
  • and finally, you can hop on IRC at irc.perl.org and try out one of the eval bots in many of the popular channels. They will evaluate chunks of perl that you pass to them.
  • 最后,您可以在IRC .perl.org上跳上IRC,在许多流行的频道中尝试使用eval机器人。它们将计算您传递给它们的perl块。

#5


18  

I use the command line as a console:

我使用命令行作为控制台:

$ perl -e 'print "JAPH\n"'

Then I can use my bash history to get back old commands. This does not preserve state, however.

然后我可以使用我的bash历史获取旧命令。然而,这并不能维持现状。

This form is most useful when you want to test "one little thing" (like when answering Perl questions). Often, I find these commands get scraped verbatim into a shell script or makefile.

当您想测试“一件小事”(比如回答Perl问题时)时,这个表单最有用。通常,我发现这些命令被逐字地剪贴到shell脚本或makefile中。

#6


14  

You can always just drop into the built-in debugger and run commands from there.

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

   perl -d -e 1

#7


14  

There isn't an interactive console for Perl built in like Python does. You can however use the Perl Debugger to do debugging related things. You turn it on with the -d option, but you might want to check out 'man perldebug' to learn about it.

没有像Python那样为Perl构建一个交互式控制台。但是,您可以使用Perl调试器来调试相关的东西。您可以使用-d选项打开它,但是您可能想要查看“man perldebug”以了解它。

After a bit of googling, there is a separate project that implements a Perl console which you can find at http://www.sukria.net/perlconsole.html.

在google一下之后,有一个单独的项目实现了一个Perl控制台,您可以在http://www.sukria.net/perlconsole.html找到它。

Hope this helps!

希望这可以帮助!

#8


13  

If you want history, use rlwrap. This could be your ~/bin/ips for example:

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

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

And this is how it looks like:

这就是它的样子:

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

#9


9  

There are two popular Perl REPLs.
1. Devel::REPL is great.
2. But IMO Reply is better.

有两个流行的Perl应答。1。猛击:REPL是伟大的。2。但在我看来,回答更好。

#10


9  

I've created perli, a Perl REPL that runs on Linux, OS X, and Windows.

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

Its focus is automatic result printing, convenient documentation lookups, and easy inspection of regular-expression matches.
You can see screenshots here.

它的重点是自动结果打印、方便的文档查找和检查正则表达式匹配。你可以在这里看到截屏。

It works stand-alone (has no dependencies other than Perl itself), but installation of rlwrap is strongly recommended so as to support command-line editing, persistent command history, and tab-completion - read more here.

它可以独立工作(除了Perl本身之外没有依赖项),但是强烈建议安装rlwrap,以便支持命令行编辑、持久命令历史记录和表完成——请在这里阅读更多内容。

Installation

安装

  • If you happen to have Node.js installed:

    如果你碰巧有节点。js安装:

    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.

      类unix平台:将此脚本下载到系统路径中的文件夹中,并使其可执行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.

      下载这个脚本作为perli。pl(注意.pl扩展名)到系统路径中的文件夹。如果你不介意调用Perli作为Perli。已经设置好了,否则创建一个名为perli的批处理文件。cmd在同一文件夹中包含以下内容:@%~dpn。pl % *;这就像perli一样支持调用。

#11


6  

perl -d is your friend:

perl -d是您的朋友:

% perl -de 0

#12


6  

re.pl from Devel::REPL

re.pl从猛击::REPL

#13


5  

I always did:

我总是做:

perl -wlne'eval;print$@if$@'

With 5.10, I've switched to:

在5.10,我切换到:

perl -wnE'say eval()//$@'

#14


4  

Perl doesn't have a console but the debugger can be used as one. At a command prompt, type perl -de 1. (The value "1" doesn't matter, it's just a valid statement that does nothing.)

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

There are also a couple of options for a Perl shell.

Perl shell还有一些选项。

For more information read perlfaq3.

更多信息请阅读perlfaq3。

#15


4  

Read-eval-print loop:

Read-eval-print循环:

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

#16


2  

You could look into psh here: http://gnp.github.io/psh/

您可以在这里查看psh: http://gnp.github.io/psh/

It's a full on shell (you can use it in replacement of bash for example), but uses perl syntax.. so you can create methods on the fly etc.

它是一个完整的shell(可以用它替换bash),但是使用perl语法。所以你可以在飞行中创建方法等等。

#17


2  

Update: I've since created a downloadable REPL - see my other answer.

更新:我已经创建了一个可下载的REPL -见我的另一个答案。

With the benefit of hindsight:

事后诸葛亮:

  • The third-party solutions mentioned among the existing answers are either cumbersome to install and/or do not work without non-trivial, non-obvious additional steps - some solutions appear to be at least half-abandoned.
  • 在现有答案中提到的第三方解决方案要么安装起来很麻烦,要么就不能正常工作,而必须有非常重要的、不明显的附加步骤——有些解决方案似乎至少被半途而废了。
  • A usable REPL needs the readline library for command-line-editing keyboard support and history support - ensuring this is a trouble spot for many third-party solutions.
  • 一个可用的REPL需要readline库来支持命令行编辑键盘和历史支持——确保这是许多第三方解决方案的麻烦点。
  • If you install CLI rlwrap, which provides readline support to any command, you can combine it with a simple Perl command to create a usable REPL, and thus make do without third-party REPL solutions.
    • On OSX, you can install rlwrap via Homebrew with brew install rlwrap.
    • 在OSX上,可以通过Homebrew安装rlwrap安装rlwrap。
    • Linux distros should offer rlwrap via their respective package managers; e.g., on Ubuntu, use sudo apt-get install rlwrap.
    • Linux发行版应该通过各自的包管理器提供rlwrap;在Ubuntu上,使用sudo apt-get安装rlwrap。
    • See Ján Sáreník's answer for said combination of rlwrap and a Perl command.
    • 请参见Jan Sarenik关于rlwrap和Perl命令的组合的回答。
  • 如果您安装了CLI rlwrap,它为任何命令提供了readline支持,那么您可以将它与一个简单的Perl命令相结合,以创建一个可用的REPL,从而无需第三方REPL解决方案。在OSX上,可以通过Homebrew安装rlwrap安装rlwrap。Linux发行版应该通过各自的包管理器提供rlwrap;在Ubuntu上,使用sudo apt-get安装rlwrap。请参见Jan Sarenik关于rlwrap和Perl命令的组合的回答。

What you do NOT get with Ján's answer:

你从简的回答中得不到什么:

  • auto-completion
  • 自动完成
  • ability to enter multi-line statements
  • 能够输入多行语句

The only third-party solution that offers these (with non-trivial installation + additional, non-obvious steps), is psh, but:

提供这些功能的唯一第三方解决方案是psh,但是:

  • it hasn't seen activity in around 2.5 years

    它已经有大约两年半没有活动了

  • its focus is different in that it aims to be a full-fledged shell replacement, and thus works like a traditional shell, which means that it doesn't automatically evaluate a command as a Perl statement, and requires an explicit output command such as print to print the result of an expression.

    它的重点是不同的,它的目标是成为一个成熟的shell替换,因此工作起来就像一个传统的shell,这意味着它不会自动地将命令作为Perl语句进行计算,并且需要一个显式的输出命令,比如print,来打印表达式的结果。


Ján Sáreník's answer can be improved in one way:

Jan Sarenik的答案可以在一个方面得到改进:

  • By default, it prints arrays/lists/hashtables as scalars, i.e., only prints their element count, whereas it would be handy to enumerate their elements instead.
  • 默认情况下,它打印数组/列表/散列表作为标量,例如。,只打印它们的元素计数,而将它们的元素列举出来是很方便的。

If you install the Data::Printer module with [sudo] cpan Data::Printer as a one-time operation, you can load it into the REPL for use of the p() function, to which you can pass lists/arrays/hashtables for enumeration.

如果您安装了带有[sudo] cpan Data:::Printer的Data: Printer,作为一次性操作,您可以将其加载到REPL中,以便使用p()函数,您可以将list /array /hashtables传递给这个函数,以便进行枚举。

Here's an alias named iperl with readline and Data::Printer support, which can you put in your POSIX-like shell's initialization file (e.g., ~/.bashrc):

这里有一个名为iperl的别名,具有readline和Data:::Printer支持,您可以将它放入您的posix类shell的初始化文件(例如,~/.bashrc):

alias iperl='rlwrap -A -S "iperl> " perl -MData::Printer -wnE '\''BEGIN { say "# Use `p @<arrayOrList>` or `p %<hashTable>` to print arrays/lists/hashtables; e.g.: `p %ENV`"; } say eval()//$@'\'

E.g., you can then do the following to print all environment variables via hashtable %ENV:

例如,您可以通过hashtable %ENV打印所有环境变量:

$ iperl        # start the REPL
iperl> p %ENV  # print key-value pairs in hashtable %ENV

As with Ján's answer, the scalar result of an expression is automatically printed; e.g.:

与Jan的答案一样,表达式的标量结果会自动打印出来;例如:

iperl> 22 / 7  # automatically print scalar result of expression: 3.14285714285714

#18


2  

Under Debian/Ubuntu:

在Debian / Ubuntu:

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

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

#19


1  

Matt Trout's overview lists five choices, from perl -de 0 onwards, and he recommends Reply, if extensibility via plugins is important, or tinyrepl from Eval::WithLexicals, for a minimal, pure-perl solution that includes readline support and lexical persistence.

Matt Trout的概述列出了五个选项,从perl -de 0开始,如果通过插件的可扩展性很重要,或者tinyrepl from Eval::WithLexicals,对于包含readline支持和词法持久性的最小的纯perl解决方案,他建议使用Reply。

#20


0  

Also look for ptkdb on CPAN: http://search.cpan.org/search?query=ptkdb&mode=all

还可以在CPAN上查找ptkdb: http://search.cpan.org/search?

#21


0  

Sepia and PDE have also own REPLs (for GNU Emacs).

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

#22


0  

See also Stylish REPL (for GNU Emacs) http://blog.jrock.us/articles/Stylish%20REPL.pod

参见时髦的REPL(用于GNU Emacs) http://blog.jrock.us/articles/Stylish%20REPL.pod

#1


246  

You can use the perl debugger on a trivial program, like so:

您可以在一个普通的程序上使用perl调试器,如下所示:

perl -de1

Alternatively there's Alexis Sukrieh's Perl Console application, but I haven't used it.

或者有Alexis Sukrieh的Perl控制台应用程序,但是我还没有使用它。

#2


52  

Not only did Matt Trout write an article about a REPL, he actually wrote one - Devel::REPL

马特·特劳特不仅写了一篇关于回购的文章,他实际上还写了一篇——回购:回购

I've used it a bit and it works fairly well, and it's under active development.

我使用了它,它运行得相当好,并且在积极的开发中。

BTW, I have no idea why someone modded down the person who mentioned using "perl -e" from the console. This isn't really a REPL, true, but it's fantastically useful, and I use it all the time.

顺便说一下,我不知道为什么有人会把使用“perl -e”的人从控制台调下来。这不是真的回购,是真的,但它非常有用,我一直在用它。

#3


33  

I wrote a script I call "psh":

我写了一个我称之为“psh”的剧本:

#! /usr/bin/perl

while (<>) {
  chomp;
  my $result = eval;
  print "$_ = $result\n";
}

Whatever you type in, it evaluates in Perl:

无论您输入什么,它都用Perl进行计算:

> gmtime(2**30)
gmtime(2**30) = Sat Jan 10 13:37:04 2004

> $x = 'foo'
$x = 'foo' = foo

> $x =~ s/o/a/g
$x =~ s/o/a/g = 2

> $x
$x = faa

#4


19  

I think you're asking about a REPL (Read, Evaluate, Print, Loop) interface to perl. There are a few ways to do this:

我认为您是在询问perl的REPL(读取、评估、打印、循环)接口。有几种方法可以做到这一点:

  • Matt Trout has an article that describes how to write one
  • Matt Trout有一篇文章描述了如何写
  • Adriano Ferreira has described some options
  • 阿德里亚诺·费雷拉描述了一些选择
  • and finally, you can hop on IRC at irc.perl.org and try out one of the eval bots in many of the popular channels. They will evaluate chunks of perl that you pass to them.
  • 最后,您可以在IRC .perl.org上跳上IRC,在许多流行的频道中尝试使用eval机器人。它们将计算您传递给它们的perl块。

#5


18  

I use the command line as a console:

我使用命令行作为控制台:

$ perl -e 'print "JAPH\n"'

Then I can use my bash history to get back old commands. This does not preserve state, however.

然后我可以使用我的bash历史获取旧命令。然而,这并不能维持现状。

This form is most useful when you want to test "one little thing" (like when answering Perl questions). Often, I find these commands get scraped verbatim into a shell script or makefile.

当您想测试“一件小事”(比如回答Perl问题时)时,这个表单最有用。通常,我发现这些命令被逐字地剪贴到shell脚本或makefile中。

#6


14  

You can always just drop into the built-in debugger and run commands from there.

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

   perl -d -e 1

#7


14  

There isn't an interactive console for Perl built in like Python does. You can however use the Perl Debugger to do debugging related things. You turn it on with the -d option, but you might want to check out 'man perldebug' to learn about it.

没有像Python那样为Perl构建一个交互式控制台。但是,您可以使用Perl调试器来调试相关的东西。您可以使用-d选项打开它,但是您可能想要查看“man perldebug”以了解它。

After a bit of googling, there is a separate project that implements a Perl console which you can find at http://www.sukria.net/perlconsole.html.

在google一下之后,有一个单独的项目实现了一个Perl控制台,您可以在http://www.sukria.net/perlconsole.html找到它。

Hope this helps!

希望这可以帮助!

#8


13  

If you want history, use rlwrap. This could be your ~/bin/ips for example:

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

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

And this is how it looks like:

这就是它的样子:

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

#9


9  

There are two popular Perl REPLs.
1. Devel::REPL is great.
2. But IMO Reply is better.

有两个流行的Perl应答。1。猛击:REPL是伟大的。2。但在我看来,回答更好。

#10


9  

I've created perli, a Perl REPL that runs on Linux, OS X, and Windows.

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

Its focus is automatic result printing, convenient documentation lookups, and easy inspection of regular-expression matches.
You can see screenshots here.

它的重点是自动结果打印、方便的文档查找和检查正则表达式匹配。你可以在这里看到截屏。

It works stand-alone (has no dependencies other than Perl itself), but installation of rlwrap is strongly recommended so as to support command-line editing, persistent command history, and tab-completion - read more here.

它可以独立工作(除了Perl本身之外没有依赖项),但是强烈建议安装rlwrap,以便支持命令行编辑、持久命令历史记录和表完成——请在这里阅读更多内容。

Installation

安装

  • If you happen to have Node.js installed:

    如果你碰巧有节点。js安装:

    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.

      类unix平台:将此脚本下载到系统路径中的文件夹中,并使其可执行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.

      下载这个脚本作为perli。pl(注意.pl扩展名)到系统路径中的文件夹。如果你不介意调用Perli作为Perli。已经设置好了,否则创建一个名为perli的批处理文件。cmd在同一文件夹中包含以下内容:@%~dpn。pl % *;这就像perli一样支持调用。

#11


6  

perl -d is your friend:

perl -d是您的朋友:

% perl -de 0

#12


6  

re.pl from Devel::REPL

re.pl从猛击::REPL

#13


5  

I always did:

我总是做:

perl -wlne'eval;print$@if$@'

With 5.10, I've switched to:

在5.10,我切换到:

perl -wnE'say eval()//$@'

#14


4  

Perl doesn't have a console but the debugger can be used as one. At a command prompt, type perl -de 1. (The value "1" doesn't matter, it's just a valid statement that does nothing.)

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

There are also a couple of options for a Perl shell.

Perl shell还有一些选项。

For more information read perlfaq3.

更多信息请阅读perlfaq3。

#15


4  

Read-eval-print loop:

Read-eval-print循环:

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

#16


2  

You could look into psh here: http://gnp.github.io/psh/

您可以在这里查看psh: http://gnp.github.io/psh/

It's a full on shell (you can use it in replacement of bash for example), but uses perl syntax.. so you can create methods on the fly etc.

它是一个完整的shell(可以用它替换bash),但是使用perl语法。所以你可以在飞行中创建方法等等。

#17


2  

Update: I've since created a downloadable REPL - see my other answer.

更新:我已经创建了一个可下载的REPL -见我的另一个答案。

With the benefit of hindsight:

事后诸葛亮:

  • The third-party solutions mentioned among the existing answers are either cumbersome to install and/or do not work without non-trivial, non-obvious additional steps - some solutions appear to be at least half-abandoned.
  • 在现有答案中提到的第三方解决方案要么安装起来很麻烦,要么就不能正常工作,而必须有非常重要的、不明显的附加步骤——有些解决方案似乎至少被半途而废了。
  • A usable REPL needs the readline library for command-line-editing keyboard support and history support - ensuring this is a trouble spot for many third-party solutions.
  • 一个可用的REPL需要readline库来支持命令行编辑键盘和历史支持——确保这是许多第三方解决方案的麻烦点。
  • If you install CLI rlwrap, which provides readline support to any command, you can combine it with a simple Perl command to create a usable REPL, and thus make do without third-party REPL solutions.
    • On OSX, you can install rlwrap via Homebrew with brew install rlwrap.
    • 在OSX上,可以通过Homebrew安装rlwrap安装rlwrap。
    • Linux distros should offer rlwrap via their respective package managers; e.g., on Ubuntu, use sudo apt-get install rlwrap.
    • Linux发行版应该通过各自的包管理器提供rlwrap;在Ubuntu上,使用sudo apt-get安装rlwrap。
    • See Ján Sáreník's answer for said combination of rlwrap and a Perl command.
    • 请参见Jan Sarenik关于rlwrap和Perl命令的组合的回答。
  • 如果您安装了CLI rlwrap,它为任何命令提供了readline支持,那么您可以将它与一个简单的Perl命令相结合,以创建一个可用的REPL,从而无需第三方REPL解决方案。在OSX上,可以通过Homebrew安装rlwrap安装rlwrap。Linux发行版应该通过各自的包管理器提供rlwrap;在Ubuntu上,使用sudo apt-get安装rlwrap。请参见Jan Sarenik关于rlwrap和Perl命令的组合的回答。

What you do NOT get with Ján's answer:

你从简的回答中得不到什么:

  • auto-completion
  • 自动完成
  • ability to enter multi-line statements
  • 能够输入多行语句

The only third-party solution that offers these (with non-trivial installation + additional, non-obvious steps), is psh, but:

提供这些功能的唯一第三方解决方案是psh,但是:

  • it hasn't seen activity in around 2.5 years

    它已经有大约两年半没有活动了

  • its focus is different in that it aims to be a full-fledged shell replacement, and thus works like a traditional shell, which means that it doesn't automatically evaluate a command as a Perl statement, and requires an explicit output command such as print to print the result of an expression.

    它的重点是不同的,它的目标是成为一个成熟的shell替换,因此工作起来就像一个传统的shell,这意味着它不会自动地将命令作为Perl语句进行计算,并且需要一个显式的输出命令,比如print,来打印表达式的结果。


Ján Sáreník's answer can be improved in one way:

Jan Sarenik的答案可以在一个方面得到改进:

  • By default, it prints arrays/lists/hashtables as scalars, i.e., only prints their element count, whereas it would be handy to enumerate their elements instead.
  • 默认情况下,它打印数组/列表/散列表作为标量,例如。,只打印它们的元素计数,而将它们的元素列举出来是很方便的。

If you install the Data::Printer module with [sudo] cpan Data::Printer as a one-time operation, you can load it into the REPL for use of the p() function, to which you can pass lists/arrays/hashtables for enumeration.

如果您安装了带有[sudo] cpan Data:::Printer的Data: Printer,作为一次性操作,您可以将其加载到REPL中,以便使用p()函数,您可以将list /array /hashtables传递给这个函数,以便进行枚举。

Here's an alias named iperl with readline and Data::Printer support, which can you put in your POSIX-like shell's initialization file (e.g., ~/.bashrc):

这里有一个名为iperl的别名,具有readline和Data:::Printer支持,您可以将它放入您的posix类shell的初始化文件(例如,~/.bashrc):

alias iperl='rlwrap -A -S "iperl> " perl -MData::Printer -wnE '\''BEGIN { say "# Use `p @<arrayOrList>` or `p %<hashTable>` to print arrays/lists/hashtables; e.g.: `p %ENV`"; } say eval()//$@'\'

E.g., you can then do the following to print all environment variables via hashtable %ENV:

例如,您可以通过hashtable %ENV打印所有环境变量:

$ iperl        # start the REPL
iperl> p %ENV  # print key-value pairs in hashtable %ENV

As with Ján's answer, the scalar result of an expression is automatically printed; e.g.:

与Jan的答案一样,表达式的标量结果会自动打印出来;例如:

iperl> 22 / 7  # automatically print scalar result of expression: 3.14285714285714

#18


2  

Under Debian/Ubuntu:

在Debian / Ubuntu:

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

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

#19


1  

Matt Trout's overview lists five choices, from perl -de 0 onwards, and he recommends Reply, if extensibility via plugins is important, or tinyrepl from Eval::WithLexicals, for a minimal, pure-perl solution that includes readline support and lexical persistence.

Matt Trout的概述列出了五个选项,从perl -de 0开始,如果通过插件的可扩展性很重要,或者tinyrepl from Eval::WithLexicals,对于包含readline支持和词法持久性的最小的纯perl解决方案,他建议使用Reply。

#20


0  

Also look for ptkdb on CPAN: http://search.cpan.org/search?query=ptkdb&mode=all

还可以在CPAN上查找ptkdb: http://search.cpan.org/search?

#21


0  

Sepia and PDE have also own REPLs (for GNU Emacs).

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

#22


0  

See also Stylish REPL (for GNU Emacs) http://blog.jrock.us/articles/Stylish%20REPL.pod

参见时髦的REPL(用于GNU Emacs) http://blog.jrock.us/articles/Stylish%20REPL.pod