Next Trivial Utilities 30

tail

How do I do a "tail -f" in perl?


        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: $!";
        }


Next Menu Copyright © 2012 M. J. Dominus