in reply to How to add input history

The module Term::Readkey may be what you are looking for.