in reply to tee -f?
I've originally wrote this code w/ a select/can_read but it ended up hogging the CPU so I put in the 1 second sleep.use IO::File; use strict; my $tail = new IO::File; $tail->open("<./log.dat"); while(1){ my @lines=$tail->getlines(); if(0==scalar(@lines)){ # wait 1 second before trying again... # to keep from hogging CPU cycles sleep 1; }else{ my $line; foreach $line(@lines){ chomp $line; print " \"$line\"\n"; } } }
A few problems with this code:
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Re: tee -f?
by Jonathan (Curate) on Jun 21, 2000 at 13:59 UTC |