开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜