in reply to Re^2: How to tail file on remote host
in thread How to tail file on remote host

Copy the whole file to your local machine and then use Algorithm::Diff or remember the last line you processed the last time and start from there.

Replies are listed 'Best First'.
Re^4: How to tail file on remote host
by Anonymous Monk on Sep 30, 2008 at 21:45 UTC
    I thought it might be easier to make the FH package global and the use the fh->clearerr so that the next time i look at the file handle I would get the new data in the file.

    With a pure filehandle this code worked for me, but I was not sure how I could get this working using this method.

    Also since most of the servers are locked down I can't easily add packages such as Algorithm::Diff.

    The code that worked for me using pure FH was something like:
    open (FH,"/tmp/file); while (<FH>) { push @result,"$_"; print "$_\n"; } FH->clearerr; return @result;
    Thanks,

    Wayne

    Thanks, Wayne

      Your code as given has syntax errors.

      I don't see what purpose the ->clearerr call is supposed to serve, as the documentation says:

      Clear the given handle's error indicator. Returns -1 if the handle is invalid, 0 otherwise.

      So it would reset the error information, but that won't change neither the eof() status nor will it read additional lines if they've been added..

      Again, as I already told you, the simple way is to just copy the remote file to your local machine and then treat the file as if it were a local file.