Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multi-Line Input

Status
Not open for further replies.

BlueBeep

Programmer
Aug 13, 2002
23
US
I'm trying to input into the console multiple lines of text. Once I press ENTER and type text, I want to be able to go back (move the cursor) to the previous line before hitting enter - sort of like a mini-editor in the console. This is for a quick email program that I'm putting together in Perl for Windows via ActiveState.

Anyway I can do this? Thanks!
 
Hmm.... not easily. You can read multiple lines of text by doing <STDIN> in a loop, but you can't backspace and go back up a line doing that. You'll need to use something more powerful, like Curses, or direct ANSI escape characters (some of them are for repositioning the insertion cursor) to do stuff like that. But with ANSI, the Win32 terminal doesn't support them all that well, so I'd have to recommend Curses, however that's a pain in the butt to install for Windows too last time I tried.

Why not use the Windows "edit" program? ;)

Code:
# create a blank file
open (WRITE, ">email.txt");
close (WRITE);

# start edit
system("edit email.txt");
# this blocks until the user finishes editing the file
# and saves it

# read what they wrote
open (READ, "email.txt");
my @email = <READ>;
close (READ);
chomp @email;

Cuvou.com | My personal homepage
Code:
perl -e '$|=$i=1;print" oo\n<|>\n_|_";x:sleep$|;print"\b",$i++%2?"/":"_";goto x;'
 
What shell environment are you running in? (eg. cmd.exe?) I ask as I have a number of routines that run under cmd.exe and I'm able to get away with simply hitting the up-arrow in order to access a short buffer of recent entries.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top