in reply to Simulating Command Line History in Perl
I've looked at the Term::Readline::* modules, but none of them seem to do this part of the task.
They do — at least on *nix (preferably install Term::ReadLine::Gnu, which has quite a few more features)
#!/usr/bin/perl use Term::ReadLine; my $term = new Term::ReadLine 'Demo'; my $prompt = 'Perl> '; while ( (my $cmd = $term->readline($prompt)) ne 'quit') { print "cmd: '$cmd'\n"; }
You can supply a second argument to readline() in case you want to suggest some default input (which can be edited).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Simulating Command Line History in Perl
by Anonymous Monk on Apr 23, 2010 at 21:23 UTC | |
by almut (Canon) on Apr 23, 2010 at 21:59 UTC | |
by Anonymous Monk on Apr 23, 2010 at 22:40 UTC | |
by bichonfrise74 (Vicar) on Apr 23, 2010 at 22:42 UTC | |
by rowdog (Curate) on Apr 23, 2010 at 22:07 UTC | |
|
Re^2: Simulating Command Line History in Perl
by Only1KW (Sexton) on Apr 23, 2010 at 21:22 UTC | |
by Only1KW (Sexton) on Apr 23, 2010 at 21:40 UTC | |
by almut (Canon) on Apr 24, 2010 at 07:28 UTC |