ignoranceisblis
03-17-2005, 05:20 AM
I'm trying to write a script to display a file in realtime
I wrote this simple script to clear the screen and then
cat the file everytime it changes but constantly opening,
reading and closing the file slows the program down
is there an easier way to do this?
#!perl
my $loop ="yes";
my $file ="/home/elliot/file";
while ($loop eq "yes") {
$old="";
open(FILE,"$file");
flock(FILE, LOCK_SH);
seek(FILE, 0, SEEK_SET);
while (my $filechk = <FILE>) {
$old="$old$filechk";
}
close(FILE);
unless($old eq $new) {
system('clear');
system('cat $file`);
}
$new=$old;
}
T.I.A.
I wrote this simple script to clear the screen and then
cat the file everytime it changes but constantly opening,
reading and closing the file slows the program down
is there an easier way to do this?
#!perl
my $loop ="yes";
my $file ="/home/elliot/file";
while ($loop eq "yes") {
$old="";
open(FILE,"$file");
flock(FILE, LOCK_SH);
seek(FILE, 0, SEEK_SET);
while (my $filechk = <FILE>) {
$old="$old$filechk";
}
close(FILE);
unless($old eq $new) {
system('clear');
system('cat $file`);
}
$new=$old;
}
T.I.A.