Getting application ReadLine and Perl debugger ReadLine to cooperate

A

Andrew DeFaria

I have an example Perl script that uses Term::ReadLine::Gnu to provide
ReadLine support with command history:

#!/usr/local/bin/perl
use Term::ReadLine;
use Term::ReadLine::Gnu;

my $term = new Term::ReadLine "test";

while () {
$_ = $term->readline ("Command:");

last if !$_;

print "Read command: $_\n":
} # while

exit;

When run it runs fine, doesn't do much, but dutifully reads commands
and stores them in the history. IOW up arrow works to recall commands
and I can edit them. IOW Term::ReadLine::Gnu is installed properly and
functioning.

Now I wish to debug this script. So I do perl -d testReadLine.pl.
Initially the Perl debugger works. I can do commands like l for list
or s for step. However, as soon as I return from the new
Term::ReadLine the debugger is confused. No command does anything.

I fully suspect that the problem lies in the fact that both my Perl
script and the Perl debugger are fighting over STDIN/STDOUT and
confusing each other. The question is how to get them both to play
nice.

Suggestions? Workarounds? Solutions?
 
B

Ben Morrow

Quoth Andrew DeFaria said:
I have an example Perl script that uses Term::ReadLine::Gnu to provide
ReadLine support with command history:

#!/usr/local/bin/perl
use Term::ReadLine;
use Term::ReadLine::Gnu;
When run it runs fine, doesn't do much, but dutifully reads commands
and stores them in the history. IOW up arrow works to recall commands
and I can edit them. IOW Term::ReadLine::Gnu is installed properly and
functioning.

Now I wish to debug this script. So I do perl -d testReadLine.pl.
Initially the Perl debugger works. I can do commands like l for list
or s for step. However, as soon as I return from the new
Term::ReadLine the debugger is confused. No command does anything.

I fully suspect that the problem lies in the fact that both my Perl
script and the Perl debugger are fighting over STDIN/STDOUT and
confusing each other. The question is how to get them both to play
nice.

It may also be because the debugger is also using Term::Readline::Gnu. I
don't know if the underlying readline library can cope with two users at
once. You may want to try the debugger options TTY and ReadLine (see
perldoc perldebug).

Ben
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top