in reply to printing deletable text to stdout

I used to do this in ksh all the time (Terminal programs), and it seems it works just as well in perl, I'm sure this isn't the best solution but it does work:

$file1 = 'c:\file.txt'; print "Enter File Here: $file1\b\b\b\b\b\b\b\b"; chomp($file2 = <STDIN>); $file2 ? $file = $file2 : $file = $file1;

"Cogito cogito ergo cogito sum - I think that I think, therefore I think that I am." Ambrose Bierce

Replies are listed 'Best First'.
Re^2: printing deletable text to stdout
by jdalbec (Deacon) on Oct 04, 2004 at 23:31 UTC
    You appear to be assuming that $file1 is eight characters long. Wouldn't print "Enter File Here: $file1", "\b" x length $file1; be preferable?

    Also, the OP wanted the user to be able to compose his response by editing the default filename. That's not possible with this solution.

      I knew there was an easier way to print multiple characters, but I don't do command line work much and as such couldn't remember it. It is possible with my solution, esp. if the "\b" x length $file was added, not to edit the default filename but to decide if one was entered or not and therefor have a default filename. Though there have been much better solutions suggested and I would recommend he use one of those.

      "Cogito cogito ergo cogito sum - I think that I think, therefore I think that I am." Ambrose Bierce