Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Greetings! I am a Perl newbie (as will soon be obvious) Here's what I want to do: From a terminal interface (text only), I print an option like "Enter the path and file name". The user then enters a path and file name (say, /home/user/file), I chomp STDIN and all is well. It would be nice on subsequent invocation of that option for the user to see "Enter the path and file name: /home/user/file" and then be able to edit the string /home/user/file by backing the cursor over the file name and replacing it (the path stays intact). It could save time on subsequent invocations with long paths. Is this practical? And if so, how do I approach this problem? I tried the simple things (like printing the variable with the old path/file to STDOUT) but this leaves the input cursor at the end of the printed string. I would like to be able to "rewind" the cursor back to beginning of the line displayed on the terminal and let that string be available for subsequent editing and input. Thanks! Mark

Replies are listed 'Best First'.
Re: interactive user interface
by pfaut (Priest) on Apr 29, 2003 at 22:23 UTC
      Thanks for the hint - it turns out I can get what I want from Term::Complete in the standard library. You are correct - most of what one needs in Perl is already written - it just takes a while for us newbies to know where to look. Mark
Re: interactive user interface
by TVSET (Chaplain) on Apr 29, 2003 at 23:18 UTC
    Additionally, if there is any chance that you can or are allowed to do so, take the filename from the command line. These really makes your software much easier to use (thanks to shell completions) and automate (thanks to command line). It would be even better, if you could read the file from STDIN, instead of asking for the path to it. Pipes are wonderful in Unix, you know. :)

    Leonid Mamtchenkov