in reply to Re^4: Reading terminal input while program is running
in thread Reading terminal input while program is running
Your while loop only executes whenever File::Tail finds a new line appended to the file you're watching. So you could do this (reformatted a bit for readability):
my $file=File::Tail->new( name => $name, maxinterval => 1, adjustafter => 1); while (defined(my $line=$file->read)) { my($logindate,$loginuser,$logoutdate,$logoutuser,$count); if($line =~ /INFO\s\s(\d+)(\d+)-(\d+)-(\d+)\s(\d+):(\d+):(\d+),(\d ++)\s\[(.*)\]\s\((.*)\) - validateLogin\((.*)\)/){ $logindate = "$1$2-$3-$4 $5:$6:$7,$8"; $loginuser = "$11"; if(($logging)&&($debug)){ &writelog(1,"DEBUG: Tail Event Login found user date strin +g = $logindate user = $loginuser"); } } if (my $inp= ReadLine (-1)) { print "Got this command: $inp"; } }
And this would work, but the loop would only check for input anytime a line is added to the log, and block until then. If you don't want to do that you'll need to use File::Tail->select instead of read, take a look at the example that comes with File::Tail and the perldoc on that.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Reading terminal input while program is running
by minixman (Beadle) on Feb 02, 2006 at 09:15 UTC |