Ok, potentially stupid/easy perl question. We all know how to open a pipe to some program and read it line by line, printing the output... You can do something like this:
This will execute some command, read from a pipe and print line by line. My prblem is, I want to read DIRECTLY from the pipe, NOT line by line. I've googled and googled, but everyone only every talks of line by line for some reason. But what if I want to read from the pipe everytime it gets flushed? Like this C++ code, for instance:
The perl code above will only display the line when it is complete (when "done" gets printed), which is obviously NOT what I'm looking for... Is there a way to just execute a program and have it print EXACTLY what the program is printing, in the same manner?
Thanks a lot!
Code:
open(EXE_PIPE, "$command |");
while(<EXE_PIPE>) { print "$_"; }
close(EXE_PIPE);
This will execute some command, read from a pipe and print line by line. My prblem is, I want to read DIRECTLY from the pipe, NOT line by line. I've googled and googled, but everyone only every talks of line by line for some reason. But what if I want to read from the pipe everytime it gets flushed? Like this C++ code, for instance:
Code:
cout << "Doing something time-consuming... " << flush;
do_something_time_consuming();
cout << "Done.\n";
The perl code above will only display the line when it is complete (when "done" gets printed), which is obviously NOT what I'm looking for... Is there a way to just execute a program and have it print EXACTLY what the program is printing, in the same manner?
Thanks a lot!
