Hacker News new | ask | show | jobs
by auraham 1378 days ago
I skimmed the article looking for a mention of a REPL or a new debugger. Perl is a great language but it lacks these tools. Sometimes I just want to try a couple of lines of Perl code in a REPL, but I cannot. Instead, I need to create a file. Also, when debugging with `perl -d`, I cannot use the Up arrow key to get the previous command. Not a big deal but the coding experience will be significantly improved with those tools.
4 comments

https://perldoc.perl.org/perldebug#Readline-Support-/-Histor...

``As shipped, the only command-line history supplied is a simplistic one that checks for leading exclamation points. However, if you install the Term::ReadKey and Term::ReadLine modules from CPAN (such as Term::ReadLine::Gnu, Term::ReadLine::Perl, ...) you will have full editing capabilities much like those GNU readline(3) provides. Look for these in the modules/by-module/Term directory on CPAN. These do not support normal vi command-line editing, however.''

There are several, highly configurable (of course) and usable REPLs.

https://metacpan.org/pod/Devel::REPL https://metacpan.org/pod/Reply

Not to mention the Jupyter kernel: https://metacpan.org/dist/Devel-IPerl

This is a simple REPL project and the readme lists other Perl REPLs.

https://github.com/viviparous/preplish

Perl's concise syntax makes working in a REPL a pleasure. Python has a REPL but the design of the language makes it expand both in length (for loops) and in width (tabs).

I am a recent convert to working in a REPL first to test programming ideas.

I think that 'perl -d' needs to have Term::Readline to be installed to provide line editing. Otherwise you could use DDD, which provides an ugly but functional GUI to gdb, and perl -d. Or ptkdb which is better IMO ('perl -d ptkdb', requires the module and Tk).
This is what I do to get that functionality:

    rlwrap perl -dee
https://linux.die.net/man/1/rlwrap