我有这段代码,它基本上是一个文件的尾部。该文件每秒填充近 100 个条目。
open (MYFILE, 'output.txt');
for (;;)
{
while (<MYFILE>)
{
chomp;
my $test=$_;
if ($test =~ m/^ok/)
{
$passed++;
print "Number of passed :$passed\n";
print "Number of failed :$failed\n";
}
elsif ($test =~ m/^not/)
{
$failed++;
print "Number of passed :$passed\n";
print "Number of failed :$failed\n";
}
elsif ($test =~ m/^The time taken is: (.*)/)
{ push (@array, "$1") ; }
$row++;
}
sleep (5);
print "It has been ".(time - $time)."seconds\n";
seek(MYFILE, 0, 1);
}
所有这些工作正常,但我希望这个 perl 脚本在文件output.txt
不再被填充时自动退出。
除了使用标志技术之外还有其他方法吗?perl做出的规定?