>>>>> "Rob" == Rob Dixon <[EMAIL PROTECTED]> writes:
I got your code running nicely, although I had to make a small change due to
an older Perl (5.004) I am using:
[...]
Rob> You need to close and reopen the file if you want to check for a rename.
Rob> Something like the program below.
Which actually emulates "tail f-" nicely, since it notices a filename
change and exits, on contrary of "tail -f" which has to be killed.
Rob> use strict;
Rob> use warnings;
Rob> use IO::Handle;
Rob> autoflush STDOUT;
Rob> use Fcntl qw(:seek);
Removed line, as seek is not yet a tag in earlier Perl.
Rob> my $file = 'junk.txt';
Rob> my $pos;
Rob> while (1) {
Rob> open LOG, $file or die "Cannot open $file, $!";
Rob> seek LOG, $pos, SEEK_SET if defined $pos;
seek LOG, $pos, 0 if defined $pos;
Rob> print while <LOG>;
Rob> $pos = tell LOG;
Rob> close LOG;
Rob> sleep 1;
Rob> }
Tx a lot, Rob!
--
Claude
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>