How to use a Read-Evaluate-Print-Loop in perl is a perennial question.
A stack overflow "interactive console for perl" question from 2008 has edits as recent as 2023 and an answer from 2021. Both org mode
and guix
make an appearance.
The winner seems to (still) be rlwrap
with an eval loop.
rlwrap -pgreen -A -S "> " perl -MData::Printer -wnE 'say eval()//$@'
Options
But there are many other solutions. Though many have not seen recent updates, Perl's backwards compatibility allows them to still be relevant.
perl -de1 | evergreen | built into perl. use with rlwrap |
perldl or pdl2 | 2024-12-11 | PDL shell (heavy install), pdl2 can use Devel::REPL |
perli | 2024-12-06 | single file CLI perl repl w/ regexp .remi and inline doc lookup |
Devel::IPerl | 2023-06-26 | jupyter notebook kernel |
Devel::REPL | 2022-05-28 | REPL with plugin infrastructure |
tinyperl | 2018-05-08 | |
reply | 2016-08-23 | |
psh | 2012-12-18 | POSIX like shell with perl, like xonsh, lish, etc. see oil's alternative shell list |
Stylish | 2011-02-27 | originally for emacs integration. has it's own repl implementation |
PDL
The Perl Data Language module is actively maintained and provides two REPL scripts. pld2
uses Devel::REPL
.
Guix
I went woolgathering with guix. The whole process a little faster than cpanm PDL
(gave up debugging), but built for perl 5.36 instead of archlinux's current-stable perl 5.40.
guix import cpan -r Devel::REPL > perl-devel-repl.scm
# edits
# * add (use-modules (guix packages) ... (gnu packages perl))
# * replace 'fill-in-yourself!'
# * disable clipboard and pastebin
# * perl-module-refresh was missing (propagated-inputs (list perl-module-install))
# * add 'perl-devel-repl' at end
guix build -f perl-devel-repl.scm
guix shell perl perl-pdl perl-term-readline-gnu -f perl-devel-repl.scm -- pdl2
jupyter
Devel::IPerl is a kernel for jupyter. It provides an iperl
script that looks like ipython.
eval $(perl -I $HOME/perl5/lib/perl5 -Mlocal::lib)
cpanm Devel::IPerl
iperl console