perl script: using Sleep() or Pause () to wait new updated data
is there any method to write a program to wait the need update text file using sleep()
function or pause()
function? The program is hanging on execution stage and once the particular file is updated and the program will开发者_如何学编程 continue its work.:
#!/usr/bin/perl
open (FILE, "/home/terrance/Desktop/perl/record.txt") || die "$!";
while(my $line = <FILE>)
{
chomp($line);
my $offset =0;
seek(FILE, $offset, 1);
print "$line\n";
sleep(0.1);
}
Do you need something like tail -f
? If yes, try File::Tail
精彩评论