How to create a history wrapper in my Perl program?

I am writing a tool that runs as a wrapper in Perl. I want it to have a story, so if you press the up arrow, go back to the previous command, just like bash or other shells. How should I do it?

- EDIT -

Thanks to daxim for pointing me to Term :: ReadLine :: Gnu. I was able to get it to work on my Linux box, and that is exactly what I was looking for. However, my main dev machine is running OS X. When I try to install the module, I get this error:

~/Downloads/Term-ReadLine-Gnu-1.19 > perl Makefile.PL Found `/usr/lib/libtermcap.dylib'. gcc-4.2 -arch i386 -arch ppc -g -pipe -fno-common -DPERL_DARWIN -fno-strict-aliasing -I/usr/local/include - DHAVE_STRING_H rlver.c -o rlver -arch i386 -arch ppc -L/usr/local/lib -lreadline -ltermcap !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! The libreadline you are using is the libedit library. Use the GNU Readline Library. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 

I am currently going through google results for this problem, but if someone had seen this before and has pointers, that would be much appreciated. Thanks!

+4
source share
2 answers

Term :: ReadLine :: Gnu is the best module for this, Term :: ReadLine :: Perl is redundant.

+3
source

Term :: ReadLine interacts with various readline packages and thus will support the story you are describing.

+1
source

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


All Articles