Jan
Jan

Reputation: 6848

How to make keyboard usable in perl debugger (and get rid of control characters)

In all my Perl installations, on very different machines using different versions of Perl (up to v5.36, which is the latest at the time of writing), upon invoking the Perl debugger using perl -d SomeModule.pm, I have trouble using the keyboard as I am used to in the shell. Readline seems broken, as if sshing to a host without exporting TERM=xterm, first. up prints ^[[A instead of accessing a history, home prints ^[[H instead of moving the cursor, end prints ^[[F, etc.

How can this be fixed?

Upvotes: 1

Views: 61

Answers (1)

Jan
Jan

Reputation: 6848

See https://perldoc.perl.org/perldebug#Readline-Support-/-History-in-the-Debugger

Readline Support / History in the Debugger

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.

A rudimentary command-line completion is also available, including lexical variables in the current scope if the PadWalker module is installed.

Without Readline support you may see the symbols "^[[A", "^[[C", "^[[B", "^[[D"", "^H", ... when using the arrow keys and/or the backspace key.

Upvotes: 1

Related Questions