in reply to Piping Tail and while loops
This is not perfect as per your specs but it does work.-f Follow. If the input-file is not a pipe, the program will not terminate after the line of the input-file has been copied, but will enter an endless loop, wherein it sleeps for a second and then attempts to read and copy further records from the input-file. Thus it may be used to monitor the growth of a file that is being written by some other process.
use IO::Select; open (F, 'tail -f somefile.log |') or die; $select = IO::Select->new(*F) or die "Unable to create select object"; while(<F>) { $lastrec = "matt: ".$_; print $lastrec; while (! $select->can_read(1)) { print $lastrec; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Piping Tail and while loops
by ikegami (Patriarch) on Sep 01, 2004 at 21:48 UTC |