I'm writing a simple program which is intended to filter
input from a pipeline. Most of the input is sent as output
untouched. Part of it is modified or used to extract
information. In its simplest form — doing nothing — the
program filter is:
$|++;
while (<>) {
print;
}
The main program sometimes outputs progress updates of its
task, overwriting the same visual content through the use of
lines ending with a carriage return. Piping such content to
filter blocks all output:
$ perl -e '$|++; print ++$a, "\r" and sleep 1 while 1' | filter
Is there an easy way to read those lines in the same loop
fashion, or should I go the sysread way? I'm looking for
something similar to what would happen if it was possible to
set the record separator to "\n or \r".