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


In reply to Using File::Tail::select with STDIN? by phillipdhall

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.