15.11. Editing Input15.11.2. SolutionUse the standard Term::ReadLine library along with the Term::ReadLine::Gnu module from CPAN:
15.11.3. DiscussionThe program in Example 15-4 acts as a crude shell. It reads a line and passes it to the shell to execute. The readline method reads a line from the terminal, with editing and history recall. It automatically adds the user's line to the history. Example 15-4. vbsh
If you want to seed the history with your own functions, use the addhistory method: $term->addhistory($seed_line); You can't seed with more than one line at a time. To remove a line from the history, use the remove_history method, which takes an index into the history list. 0 is the first (least recent) entry, 1 the second, and so on up to the most recent history lines. $term->remove_history($line_number); To get a list of history lines, use the GetHistory method, which returns a list of the lines: @history = $term->GetHistory; 15.11.4. See AlsoThe documentation for the standard Term::ReadLine module and the Term::ReadLine::Gnu from CPAN
Copyright © 2003 O'Reilly & Associates. All rights reserved. |
|