On Sun, 2007-08-05 at 18:26 +0100, Jorge Almeida wrote: > 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...
It sounds like you want something similar to parameter handling, generally this works on escalating files. eg /etc/myprog overridden by ~/.myprog overrridden by a specific options file and so on. The trick is simply to read them in that order and then just use what is left. So if /etc/myprog sets key X and ~/.myprog changes key X to some other value then the last one to change wins. You just have to set them up in the right order and it is not that hard. -- Ken Foskey FOSS developer -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
