In general, no, this is not standard behavior. I say "in general" becuase this is really a system dependent issue. When perl reads from the standard input, it's not actually looking at what you type on the keyboard, it's asking the operating system to tell it what you're typing. (Yes, I'm oversimplifying a great deal here. The specifics depend on what OS you're running, though.) This way, you can, with a command line like (on DOS or Linux, respectively)
C:\ perl myscript.pl < inputfile
bash$ myscript.pl < inputfile
Then perl gets the contents of
inputfile fed to it as it's standard input.
Anyway, I see 3 possible causes for your problem.
- You're using some bizarre OS that doesn't recognize backspace properly. I'd imagine this is unlikely, as most people who use bizarre OSes tend to know about that sort of quirk (and claim that it's a feature ;)
- You're running the script on a shell account on a remote computer, and your telnet program is sending the wrong character as a backspace. Again, even if you are telneting, this is unlikely, as you'd have problems backspacing on everything, not just this script.
- The most likely cause is that, for whatever reason, the script either isn't using standard input, or has used Term::ReadKey to put the input into "raw" mode.
The answer to question 2, then, is don't worry about it. Just use STDIN, and all should be fine. If you're really concerned, run this and see if backspace works:
#!/usr/bin/perl -w
while (<>) {
print "You typed: $_\n";
}
--
Ryan Koppenhaver, Aspiring Perl Hacker
"I ask for so little. Just fear me, love me, do as I say and I will be your slave."