open (tlog,"<c:\\tlog1.log") or die $!;
seek(tlog,0,2);
while(1){
my $in = <tlog>;
if( $in XXXX){ XXXXXXXX};
sleep 1; # 加上CPU下来了,只有3%左右
}作者: flw 时间: 2011-06-24 18:18
太牛了啊!!!佩服佩服!作者: ulmer 时间: 2011-06-24 19:38
That is classic and very old method for tail -f in perl!!!
my $file = 'test.log';
open (LOG, $file) or die $!;
for (;;) {
print <LOG>;
sleep 1;
seek (LOG, 0, 1);
}
See perldoc perlfaq5, man pause作者: newstudent2011 时间: 2011-06-25 12:26 本帖最后由 newstudent2011 于 2011-06-25 12:37 编辑