binary* has asked for the wisdom of the Perl Monks concerning the following question:

I am working my way through Learning Perl (unix version). Many of these examples us CTRL D to interrupt keyboard input and allow the program to continue processing that input.
chomp (@strings=<STDIN>); # do something with the strings
This works fine on my linux box, but when I try it on my laptop, I get a plus sign. Is there a keystorke combination in windows that correspondes to CTRL-D in linux?

Thanks

Edit kudra, 2001-10-06 Added markup

Replies are listed 'Best First'.
Re: windows keyboard input
by John M. Dlugosz (Monsignor) on Oct 06, 2001 at 02:07 UTC
    If the reply on ^Z wasn't what you had in mind, then maybe you should clarify.

    If a program is running and reading from stdin, then pressing ^Z on Win32 (or ^D on Unix) will make the program see EOF on that file handle.

    So if you wrote:

    @a= <>;
    then typed a bunch of stuff, ^Z would terminate the array-read and let the program go on. E.g.
    @a= <>; foreach (@a) { $total += $_; ++$count; } print "total of $count items is $total\n";
    Running it,
    1 2 5 6 ^Z total of 4 items is 14
      That was very helpful! I had STDIN inside the diamond operator which works fine on linux, but doesn't on windows. Eliminating STDIN inside the diamond brackets allows CTRL-Z to work as expected. In linux, the keyboard interruption works with CTRL-D for both the empty diamond operator on the diamond operator with STDIN inside. Thanks
        I'm glad to help.

        diamond or STDIN work the same in my example. Are you wanting more than one array read in the same program? There I can see a difference, since diamond will try the "next file" and I suppose reopens stdin.

        —John

Re: windows keyboard input
by czarfred (Beadle) on Oct 06, 2001 at 00:46 UTC
    From the Llama Book (Unix 2nd Ed):

    "...delimit the end of the list by pressing your EOF character probably CTRL-D under UNIX or Plan9; often CTRL-Z elsewhere."

    Should work- hope it helps...
      When I try CTRL-Z, my program stops and the command prompt comes back. all program steps after the reading from STDIN are not executed. Thanks anyway.