abhishes has asked for the wisdom of the Perl Monks concerning the following question:
Today I felt the urge to write on own tail utiltity (I work on W2k with perl Active State perl 5.8).
So I looked up CPAN and found File::Tail (version .98).
Here is the code I wroteuse warnings; use strict; use File::Tail; my $param = shift; my $file = new File::Tail(name=>$param, maxinterval=>1, adjustafter=>1 +); while(defined(my $line=$file->read)) { print "$line"; }
Now to test this code I create a file called fox.txt and saved it without any data in it.
I ran the script with the command (perl tail.pl fox.txt). Now I added the line "quick brown fox jumps over the lazy dog" to the fox.txt file and saved it. Nothing happened my tail utiltity printed nothing.
Next, I added a new line called "1 2 3" to the fox.txt.
Now the tail utiltity printed my first line "quick brown fox jumps over lazy dog". but not the "1 2 3".
Then I added another line "4 5 6" to the file and saved it. Now the utility printed "1 2 3".
This is not the behavior which I expected. I expected that my utility will print the lines which I added in the most recently saved file. I read the readme file but it didn't say that it is not compatible with my windows platform. So what wrong? why is it not working properly?
Please help.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: File::Tail behaves funny
by The Mad Hatter (Priest) on Apr 07, 2003 at 20:27 UTC | |
|
Re: File::Tail behaves funny (final newline)
by tye (Sage) on Apr 07, 2003 at 23:07 UTC | |
by abhishes (Friar) on Apr 08, 2003 at 10:07 UTC | |
|
Re: File::Tail behaves funny
by BrowserUk (Patriarch) on Apr 07, 2003 at 21:26 UTC | |
|
Re: File::Tail behaves funny
by Mr. Muskrat (Canon) on Apr 07, 2003 at 20:31 UTC | |
by abhishes (Friar) on Apr 07, 2003 at 20:41 UTC |