开发者

perl script: using Sleep() or Pause () to wait new updated data

开发者 https://www.devze.com 2023-02-21 22:15 出处:网络
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 a

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

精彩评论

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