in reply to Feeding values to an existing program

It seems like you could use a piped open to feed values to its standard in and then just redirect it output to a logfile. Something like this:

open(PROG,"|program > logfile")

while $data = <DATASOURCE>{

print PROG $data;

}

This will open "program" and redirect its output to "logfile", leaving you with a pipe ti its stdin. You can write to this pipe through the filehandle "PROG"

The drawback of this approach is that it is not very sophisticated (does your program 'prompt' when it wants input, or does it constantly accept it, expect would help if the former is the case), but the value is that it is simple.

  • Comment on Re: Feeding values to an existing program