On 2/17/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I want to learn how to build line editing ability into a homemade perl > script I wrote. > > The script takes in keyboard input and formats it, also adding > specific lines to the beginning and end. Making input into a blerb in > a homemade flat database. Nothing complex just markers fore and aft > to make searching work in chunks. > > A blub ends up like: > > Keywords: Here will appear the first line of keyboard input > 021606_051734 <= formated date appears here > Now we see any other lines of input followed by double ampersand. > && > > When the script sees a dot on a line by itself followed by a carriage > return it closes and prints the added info and keyboard input to a > database. > > Input is handled with simple <STDIN> type stuff. > > This is all pretty nifty for homemade stuff, except that the input > lines can not be edited as they go in. I mean I can't backup and > redo handily like one can in vi or whatever. > > Its the kind of thing you can see at the command line if you say: > cat <enter> > somthing > > Then try to walk back with arrow keys to insert the missing `e'. > You can do it with backspace but then you have to erase everything up to > the `e'. Using arrow keys you get: > cat > somthing^[[D^[[D^[[D^[[D > > So cutting to the chase here, I'd like some basic line editing > capability and don't really have a clue as to where to start. > > I hoped someone here might point me in the direction I need to look. > >
CPAN is your friend; there are many modules that implement this kind of support in various ways, depending on your needs. Term::ReadLine is the stanard module for readline support and should be part of the default install. Shell::Base, Term::ReadLine::Zoid::(vi|emacs) also spring to mind. HTH, -- jay -------------------------------------------------- This email and attachment(s): [ ] blogable; [ x ] ask first; [ ] private and confidential daggerquill [at] gmail [dot] com http://www.tuaw.com http://www.dpguru.com http://www.engatiki.org values of β will give rise to dom!