Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
除了使用模块 File::Tail (用于从不断更新的文件中读取的 Perl 扩展)o while 循环 .. 根据您的说法,实时读取大日志文件的最佳方法是什么?
读取文件直到eof,休眠一段时间,清除文件句柄上的 eof 标志,然后再次尝试从中读取,
eof
# open $fh.. while (1) { while (my $line = <$fh>) { # $line ... } # eof reached on $fh sleep 1; # clear eof flag on $fh seek($fh, 0, 1); }
您可以使用模块sleep缩短Time::HiRes
sleep
Time::HiRes