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

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

Replies are listed 'Best First'.
Re^5: How to tail file on remote host
by Corion (Patriarch) on Oct 01, 2008 at 06:20 UTC

    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.