Jim Gibson <jimsgib...@gmail.com> writes:

> On 10/19/09 Mon  Oct 19, 2009  11:38 AM, "Harry Putnam" <rea...@newsguy.com>
> scribbled:
>
>
>> 
>> I'm not sure what it is about the tail -f command that allows it to
>> keep reading over restarts of system logger (on Opensolaris)... but
>> how can I emulate whatever it is.. in perl?
>> 
>
> There is an FAQ:
>
>     perldoc -q tail
>
> See if that helps you.
>
> The idea is to read until the end-of-file is reached, pause for awhile, then
> try reading again. However, reaching EOF sets a flag in the file handle and
> subsequent reads will fail. The trick is to reset the EOF flag with a seek
> command, either
>
>     seek($fh,0,1)
>
> or
>
>     $curpos = tell($fh);
>     seek($fh,$curpos,0);

It all sounds good so trying a simple example like the one below. 

But being A bit unsure.. I can report that this simple example seems
to work... at least in so far as surviving repeated restarts of
system.logger.  Am I making some non-obvious mistake here?

  open(FILE,"<./named-pipe") or die "Can't Open ./named-pipe: $!";
  while(<FILE>){
    print;
    if(eof){
      sleep 2;
      seek (FILE,0,1);
    }
  } 
   



-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to