First of all, a huge thank you to all the monks! I am on only my second Perl project, and y'all have made the journey successful. The answers available here have carried me through without ever having to ask my own question (until today)! That said...
My project tails a log (File::Tail) looking for a specific log entry. It then presents related data to the user. I want the user to be able to enter commands that alter the way the data is presented.
sub watch {
my $tail = File::Tail->new(
name=>"$filepath",
interval=>1,
maxinterval=>2,
resetafter=>17
);
my @handles= ($tail, \*STDIN);
while (1) {
my (undef, undef, @pending) =
File::Tail::select(undef, undef, undef, .5, @handles);
foreach (@pending) {
if ($_ == $tail) {
my $line = $_->read();
<is it line I'm looking for... if so do blah...>
}
else { # assume STDIN
<read user command, execute>
}
}
}
}
I can do this successfully using multiple files, but if I use \*STDIN, I get the following error when the watch() function is called:
Can't locate object method "predict" via package "FileHandle" at /mnt/home/phall/Scripts/lib/File/Tail.pm line 473.
Any guidance what the RIGHT way to do this is?
Thanks,
Phil