Next | Welcome to my ~/bin | 22 |
A Frequently Asked Question is:
How do I do a "tail -f" in perl?
That's not hard:
my $file = shift or die "Usage: $0 filename\n"; open my($fh), "<", $file or die "$file: $!\n";
while (1) { while (<$fh>) { print; } sleep 1; seek $fh, 0, 1 or die "seek: $!"; }
The tricky part here is the seek
I don't use this particular program, because tail -f does the same thing
But starting from this base, we can do some interesting things
Next | Menu | Copyright © 2005 M. J. Dominus |