Term::Shell is excellent scaffolding and support when you do not want to muck around with Term::Readline yourself. As long as you have one of the Term::Readline:: alternatives installed, you get command-line editing and history for free.
knan@viconia:~$ perl ./listing3.pl
World domination. But first, take care of the spam.
No spam. Yet.
Unknown command '?'; type 'help' for a list.
Type 'help command' for more detailed help.
exit - exits the program
help - prints this screen, or help on 'command'
ls - Is there any spam? - no help available
So far so good. Add a help_ls subroutine if you feel like explaining the intricacies of spam listing to your fellow spam handlers.
Source of the shell above:
use base qw(Term::Shell);
$state_path = "";
print "World domination. But first,"
."take care of the spam.\n";
return "spsh:/$state_path> ";
# Define an empty command, to avoid
# "unknown command" on an empty
print "No spam. Yet.\n";
return "Is there any spam?"