revdiablo has asked for the wisdom of the Perl Monks concerning the following question:
To start off, I am talking from a unix point of view. I know EOF is not a character, and it doesn't seem to be a unix signal. So, what is it?
The reason I ask, is because I have a program that wants to read two separate streams from STDIN. Example:
perl -e 'print "1:$_" while <>; print "2:$_" while <>;'
When run directly from the terminal, you can type a few lines of input, press ^D, type a few more, and press ^D again. Everything works as expected: the first while loop gets the first stream of input, the second gets the second.
Now, the question is, how to do what the terminal does when ^D is pressed? It's not sending the ^D char. It's catching the ^D keypress, and doing something. I looked in man bash for some guidance, and all it says is:
delete-char (C-d) Delete the character at point. If point is at the beginning of the line, there are no characters in the line, and the last character typed was not bound to delete-char, then return EOF.
So, apparently bash "return[s] EOF," but what exactly is the EOF that it is returning, and how can I do that from a Perl program?
Any ideas will be appreciated.
Update: clarified a bit
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: what is EOF and how can I send it? (0 bytes read)
by tye (Sage) on Jun 05, 2004 at 05:16 UTC | |
by Anonymous Monk on Jun 14, 2012 at 22:18 UTC | |
|
Re: what is EOF and how can I send it?
by toma (Vicar) on Jun 05, 2004 at 07:02 UTC | |
|
Re: what is EOF and how can I send it?
by virtualsue (Vicar) on Jun 05, 2004 at 06:43 UTC | |
|
Re: what is EOF and how can I send it?
by graff (Chancellor) on Jun 06, 2004 at 15:08 UTC | |
by revdiablo (Prior) on Jun 06, 2004 at 15:45 UTC |