FYI, when you type CTRL-D, the tty driver echos back 4 characters ^D\b \b (where \b is <CTRL-H> or backspace). So when perl outputs its first line, it writes 3\n (which the tty driver converts to 3\r\n), so the ^ is overwritten by the 3, leaving 3D.

Edward Moy
Apple

On Feb 1, 2006, at 10:01 AM, Jonathan Levi MD wrote:

At 4:13 PM +1030 2/1/06, Paul McCann wrote:
Jonathan Levi wrote:

#!/usr/bin/env perl
   # [comments omitted]
   print reverse <>;

drj2:learningperl4 jonathan$ p052e1.pl
...
   3
   3D
..

I'm pretty sure that you're just seeing an artefact of executing in the terminal (ie it's a display problem, rather than a problem with the output).

If you try to "catch" the output instead, via

p052e1.pl > output.txt

and then "less output.txt" you should notice that the "^D" terminated input gives the same result as when you point at a file for the input.

You were right, the stray "D" didn't appear in output.txt, so I don't have to worry about it creeping into output files. Many thanks, Jonathan

Reply via email to