Perl REPL

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 -de1evergreenbuilt into perl. use with rlwrap
perldl or pdl22024-12-11PDL shell (heavy install), pdl2 can use Devel::REPL
perli2024-12-06single file CLI perl repl w/ regexp .remi and inline doc lookup
Devel::IPerl2023-06-26jupyter notebook kernel
Devel::REPL2022-05-28REPL with plugin infrastructure
tinyperl2018-05-08
reply2016-08-23
psh2012-12-18POSIX like shell with perl, like xonsh, lish, etc. see oil's alternative shell list
Stylish2011-02-27originally 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

..