Reputation: 1514
I'm learning perl in free time and I'm trying to write simple script that will open and refresh certain file. The snippet below should open the file and write it to standard output. And it does, but unfortunately, its printing the file without last line.
Any ideas why?
use strict;
use warnings;
my $filesizeold = 0;
while(1){
my $filesize = -s "input.txt";
if($filesize != $filesizeold) {
system $^O eq 'MSWin32' ? 'cls' : 'clear';
open INPUT, "<input.txt";
while ( <INPUT> ) {
print;
}
close INPUT;
}
$filesizeold = $filesize;
}
Upvotes: 1
Views: 556
Reputation: 21676
Maybe there's something like println instead of print?
Yes there is, you can use say
.
http://perldoc.perl.org/functions/say.html
Its printing the file without last line
I think you are suffering from buffering.
Upvotes: 2