The default setting of File::Tail behaves the way you want. Perhaps that is an easier solution.
- Mark. > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On > Behalf Of [EMAIL PROTECTED] > Sent: Tuesday, February 22, 2005 9:03 AM > To: perl-unix-users@listserv.ActiveState.com > Subject: Re: [Perl-unix-users] subscriber > > > I use the following to tail a growing file and exist on key > hit. This code is pretty much straight from the Perl CD > Bookshelf. I'd like to know how I could possibly seek to the > last line of the file ~at the time of execution~ so as to not > have to print the whole file each time this program is run. > This would be useful against very large files of course. Even > the current eof line pos - 100 lines at the time of execution > would work. Thanks for any tips. > > > > > use Term::ReadKey; > use IO::Handle; > > my $key; > my $nohupfile="nohup.out"; > > open (NOHUPFILE, $nohupfile) or die "can't open $nohupfile: > $!"; while (!$key) { > $key=ReadKey(-1); > if ($key) { > last; > } > while (<NOHUPFILE>) { > print > } > if (!$key) { > sleep 1; > } else { > last; > } > NOHUPFILE->clearerr(); > } > > > _______________________________________________ > Perl-Unix-Users mailing list Perl-Unix-Users@listserv.ActiveState.com > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > _______________________________________________ Perl-Unix-Users mailing list Perl-Unix-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs