in reply to Re: Simulating Command Line History in Perl
in thread Simulating Command Line History in Perl

I tried your code but it doesn't give the capabilities to do up and down for the history which is what the op wanted.
  • Comment on Re^2: Simulating Command Line History in Perl

Replies are listed 'Best First'.
Re^3: Simulating Command Line History in Perl
by almut (Canon) on Apr 23, 2010 at 21:59 UTC

    Works for me.  I.e., type "foo" at the prompt, followed by <Enter>. New empty prompt appears. Hit cursor up, and "foo" is back for you to edit.  This is what I understood the OP wanted...

    If that doesn't work, you're likely either on Windows, or don't have Term::ReadLine::Gnu installed.

      It still doesn't work for me... I have Term::ReadLine::Gnu installed.
        This sounds crazy but maybe you are on Windows???
Re^3: Simulating Command Line History in Perl
by rowdog (Curate) on Apr 23, 2010 at 22:07 UTC

    Term::ReadLine will pick from a number of different backends depending on what's available. My custom built perl finds Term::ReadLine::Gnu and works just fine. My system perl, which I never touch, found Term::ReadLine::Stub which does not work correctly, because it's just a stub.

    Add this line to almut's code to see your backend.

    print "Using ", $term->ReadLine, "\n";