-2

I attempted to write a Perl script to take user input. I am on Windows 8 and Cygwin.

When I try to run my code it expects user input as it should, but when I attempt to press Ctrl-D the program still tries to accept input instead of signalling the end of input.

Here is my code below. Why is this the case? Is there a way I can overcome this without switching away from Cygwin? I do not want to press Ctrl-Z or Ctrl-C as I don't want to stop the execution of the program.

#!/usr/bin/perl

while ( $line = <> ) {
    print $line;
}
Borodin
  • 126,100
  • 9
  • 70
  • 144
Jason J
  • 1
  • 1
  • 1
    It's strange that you haven't even *tried* Ctrl-Z before asking for help – Borodin Aug 25 '15 at 11:25
  • @Jason J, If you're using a cygwin build of Perl, you'd use Ctrl-D since that signals EOF on unix systems like cygwin. But you appear to be using a Windows build of Perl (ActivePerl? Strawberry Perl?). Ctrl-Z signals EOF in Windows. – ikegami Aug 26 '15 at 03:44

1 Answers1

1

In Windows you have to use CTRL-Z instead of CTRL-D.

Sinan Ünür
  • 116,958
  • 15
  • 196
  • 339
Chankey Pathak
  • 21,187
  • 12
  • 85
  • 133