phillipdhall has asked for the wisdom of the Perl Monks concerning the following question:
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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Using File::Tail::select with STDIN?
by Athanasius (Archbishop) on Aug 12, 2012 at 03:57 UTC | |
by phillipdhall (Initiate) on Aug 12, 2012 at 14:41 UTC | |
Re: Using File::Tail::select with STDIN?
by zentara (Cardinal) on Aug 12, 2012 at 11:57 UTC | |
by phillipdhall (Initiate) on Aug 25, 2012 at 11:07 UTC | |
Re: Using File::Tail::select with STDIN?
by aitap (Curate) on Aug 12, 2012 at 09:52 UTC |