in reply to what is EOF and how can I send it?

Talking from a unix point of view, I have to ask for yet a little more clarification on this point:

I have a program that wants to read two separate streams from STDIN.

In unix, a data file is also referred to as a "stream". Since your example just uses  while <>, I wonder if you're talking about a case where two files (streams) are being presented to the script via ARGV, like this:

some_script.pl file1 file2
If that is what you mean, then you just need to study the explanation given by "perldoc -f eof", which includes the following:
In a "while (<>)" loop, "eof" or "eof(ARGV)" can be used to detect the end of each file, "eof()" will only detect the end of the last file. Examples: ...
An example relevant to your post would be:
my $prefix = 1; while (<>) { print "$prefix: $_"; $prefix++ if ( eof ); }
The only other situation I can imagine for the "two streams on STDIN" would be something like this:
cat file1 file2 | some_script.pl # or something less mundane: grep "target string" file1 | cat - file2 | some_script.pl
Of course, the whole point of the unix "cat" command is to concatenate two or more streams into a single stream, so in cases like this, the perl script is really only getting one stream, and unless there are reliable clues in the data content to indicate the different sources, the script will have no basis for telling one source from another -- it really is just one stream to the perl script, and there's no way around that.

(update: I should say, the only way around that is to make sure there are reliable clues in the resulting stream -- e.g.:

echo "____STREAM_BOUNDARY____" > bndry grep "target string" file1 | cat - bndry file2 | script.pl
and you fix script.pl so that it knows to look for the specific string that flags the stream boundary.)

In the earlier case, where the script is given two or more file names in @ARGV, and these are read successively by the diamond operator, perl obviously knows when one file ends and the next must be opened, and "eof" is how you find out about that.

If your notion of "two streams on STDIN" is referring to something other than these cases, then I'm puzzled as to what you could be talking about.

Replies are listed 'Best First'.
Re^2: what is EOF and how can I send it?
by revdiablo (Prior) on Jun 06, 2004 at 15:45 UTC

    Sorry for any confusion it might have caused, but I used the diamond operator simply for convenience. Pretend that instead of <>, I had written <STDIN>, and it might make more sense. How to read the streams wasn't the question I had, however. In fact, the reading program was out of my control anyway. I found it odd that it was able to read two separate streams interactively, and I wondered how to write them both to STDOUT. tye's response clarified that bit for me, specifically where he wrote:

    flushing again with CTRL-D means that 0 bytes get flushed to the next read request (and so gets interpretted as EOF).

    And toma's response explained how I can emulate the terminal's behavior from a non-interactive perl script. Thanks for taking the time to reply, though.

    Update: btw, just to pass along a neat little trick, if using bash (or perhaps other shells support this, but only tested on bash) you could avoid the temporary file in your last example with something like:

    grep "target string" file1 \ | cat - <(echo "____STREAM_BOUNDARY____") file2 \ | script.pl