How can I identify and process control characters and arrow keys in Perl?

I want to implement command line functions, for example in linux terminal. I also saw this on the ftp command.

  • If I click the tab, I need to specify the commands.
  • If I press control characters, I need to get these characters based on the fact that I will do some action.
  • And if I give commands, they must be executed.

For this, I tried with Term :: ReadKey , which is in noncanonical mode. But here I encounter a lot of problems, for example, if I press any control symbol or arrow, I have three symbols. For the up arrow, I got ASCII 27 91 65.

Can someone help me solve this problem?

+3
source share
3 answers

I have one Perl module to fully satisfy my requirements. Term :: ShellUI .

Thanks for all your inputs.

And if you have any other solution, always welcome.

+2
source

I think Term :: Readline will be your best bet .

+2
source

, Term::ReadLine . readline.

Term :: ReadLine :: Gnu , Term :: ReadLine :: Perl and Term :: ReadLine :: Zoid can execute user termination. Term :: ReadLine :: Gnu is probably the most documented . Term :: ReadLine :: Perl is almost undocumented, and I have no experience with Term :: ReadLine :: Zoid.

+2
source

Source: https://habr.com/ru/post/1737281/


All Articles