> PERLDB_OPTS="TTY=`tty` ReadLine=0" xterm -e perl -d ./calc_TRL.pl
Loading DB routines from perl5db.pl version 1.33
Editor support available.
Enter h or `h h' for help, or `man perldebug' for more help.
main::(./calc_TRL.pl:2): my $term = Term::ReadLine->new('Simple Perl calc');
DB<1> l
2==> my $term = Term::ReadLine->new('Simple Perl calc');
3: my $prompt = "Enter code: ";
4: my $OUT = $term->OUT || \*STDOUT;
5: while ( $_ = $term->readline($prompt) ) {
6: my $res = eval($_);
7: warn $@ if $@;
8: print $OUT $res, "\n" unless $@;
9: $term->addhistory($_) if /\S/;
10 }
11
DB<1> b 9
DB<2> c
main::(./calc_TRL.pl:9): $term->addhistory($_) if /\S/;
DB<2> c
main::(./calc_TRL.pl:9): $term->addhistory($_) if /\S/;
DB<3>
####
Enter code: 1+2
3
Enter code: 4+4
8
##
##
> cat ./calc_TRL.pl
use Term::ReadLine;
my $term = Term::ReadLine->new('Simple Perl calc');
my $prompt = "Enter code: ";
my $OUT = $term->OUT || \*STDOUT;
while ( $_ = $term->readline($prompt) ) {
my $res = eval($_);
warn $@ if $@;
print $OUT $res, "\n" unless $@;
$term->addhistory($_) if /\S/;
}