On Sun, 5 Aug 2007, John W. Krahn wrote:
Jorge Almeida wrote:
Is there some variable that will do for a file what $/ does for a
record?
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.
OK, I suppose there is no way to do it...
I have an interactive, shell-like, program. Some commands read a line
from STDIN, or the whole STDIN (meaning until CTRL-D is pressed). Now I
want to modify the program to have a batch mode. Commands would be read
from STDIN (probably redirected from a file), as well as the data, if
any. The problem is how to keep the data for several commands in the
same file. One command would read a part of the data (as if it were the
whole input), the next command would read the next part, and so on. But
since some commands pass the input through the shell before using it, I
can't just read a chunk until some special character is found and call
it "the whole" stdin...
Impossible task, probably...
--
Jorge Almeida
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/