in reply to Piping Tail and while loops

use the -f option on tail
from the man pages...
-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.
This is not perfect as per your specs but it does work.
Also, your while will then be infinite so you might need some condition to exit out of it.

update:
as ikegami points out your --follow=name is something (if not exactly) like the -f option. My system (sun) does not appear to have the same option.

another update:
here's an example of what ikegami is talking about...
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
    He's already using -f (by the alternate name --follow). The OP's problem is that <> is blocking (as it usually is), and he wants it to be non-blocking.