Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trapping arrow keys

I have a utility that I use as a pseudo "shell". It basically while()'s stdin for commands and runs them through different subroutines.

My question is, is there a module or some example I can use to work toward trapping the up arrow so that I can have it perform a certain action? I plan to incorporate a previous command function similar to bash.

Right now, if I press the up arrow I get this:

patrick@utility$ ^[[A^[[A^[[A^[[A

Thanks in advance.

like image 998
Patrick Avatar asked Jan 13 '10 22:01

Patrick


1 Answers

Try Term::ReadLine module

like image 62
Ivan Nevostruev Avatar answered Oct 23 '22 04:10

Ivan Nevostruev