Jorge Almeida wrote:
Is there some variable that will do for a file what $/ does for a record? What I mean is that in $s=<STDIN> the value of $s depends on the value of $/, but in @arr=<STDIN> I couldn't find a way to force the reading to stop when some character is found.
There is no "eof" character in modern operating systems, Back in the days of CP/M (does anyone else here remember CP/M) they used an "eof" character because the file system did not keep a record of file sizes so the only way to determine if the file had ended was to assign a special character that marked the file end. AFAIK all modern file systems store the file size so it is very easy to determine when the end of the file is reached by keeping track of how many bytes have been read.
In Unix (<Ctrl>-D) or in DOS/Windows (<Ctrl>-Z) the "eof" character is just a signal to the terminal/console that there is no more data left and the actual character is not included as a part of that data.
Note that reading STDIN line by line and checking for a character won't do the job, because somewhere in the program I need something like open(F,"do-something|"); while(<F>){...} and later open(G,"do-something-else|") while(<G>){...} So, assuming that the program's standard input is redirected from some file, I would need a way to divide the file into chunks, so that each chunk would be treated as the whole STDIN each time @arr=<STDIN> or open(F,"do-something|") appears in the program.
If you are redirecting input through a pipe there is no way to determine file boundaries.
John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low cost and in short order. -- Larry Wall -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/