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

Hi im new to perl. I read that in Standard Input <STDIN> the EOF from windows is Ctrl+z and from Unix its Ctrl+D. but when i tried to finish the set of inputs by pressing Ctrl+z from windos cmd it was also give as an input to the program printed as "^Z". Is there any other keys that can be used as an EOF. I tried Ctrl+c but it merely exite me from the program. I m using a Windows Vista Lap. with perl 5.12.2. please help me out.
  • Comment on How to give an EOF from windows Standard input?

Replies are listed 'Best First'.
Re: How to give an EOF from windows Standard input?
by BrowserUk (Patriarch) on Feb 11, 2011 at 16:25 UTC

    I also use Vista and I don't see this:

    c:\test>perl -nlE" say qq[>$_<]; " CON fred >fred< bill >bill< john >john< ^Z c:\test>perl -E" say qq[>$_<] while <STDIN>" fred >fred < bill >bill < john >john < ^Z

    Perhaps you could post a small program and console log to demonstrate the problem?


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      I've noticed that when I'm in a cmd window under windows the ^Z for eof is ignored until after I have hit enter. I.E. I have to use ^Z followed by enter. Perhaps that's what he meant?
      hey i got the issue i was giving Ctrl+Z then followed by some other commands. may be that caused the problem..now it works fine .. Also when i tried to run the perl script not from the command prompt directly from the perl for ex: the code #!/usr/local/bin/perl -w @lines= <STDIN>; print "@lines"; print"This is new \n"; i saved it as input.pl and when i clicked on that from the folder the prompt window was shown i was able to give the inputs and when i pressed Ctrl+Z the window was closed without showing the "This is new" text. How can i make my prompt window stay.

        Please use <code></code> tags around code in your posts.

        The console window will close as soon as the script ends. If you want the window to stay a round for a few seconds, add a sleep before it terminates:

        #!/usr/local/bin/perl -w @lines= <STDIN>; print "@lines"; print"This is new \n"; sleep 60;

        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.
        Depends whether you want the console window, which is what is generated for perl, or a cmd.exe shell. If it is a cmd.exe shell you want then run your perl script from a short-cut or association with:
        %comspec% /k perl c:\gash.pl
        where c:\gash.pl is the path to the script. It will run the script then give you a prompt.