penantes has asked for the wisdom of the Perl Monks concerning the following question:

Hi there. I have a couple of perhaps simple questions. How can I use a "use strict" with a format SOMETHING = @<<<...etcetc . without having to leave it to STDOUT...
I'm creating a logwatcher that uses an open(FH,"tail -f $file|") to get the inputs but I really don't like this solution can somebody hint me with something else not system commands dependent. Something like sysopen with buffers and is there any solution not time dependent?
Best Regards,
Thanks 2 ALL
Nuno A

20050212 Edit by castaway: Changed title from 'First Timer both in perlmonks and perl...'

  • Comment on use strict with format and tailing a file

Replies are listed 'Best First'.
Re: use strict with format and tailing a file
by ysth (Canon) on Feb 10, 2005 at 23:13 UTC
    For the first question, I'm not sure what you are asking. Can you show a little code?

    For the second, File::Tail.

      Sure, but only tomorrow its almost midnight here in Portugal and I only have the code at work, then I can show you both code and error while trying use a personal defined format name...
      Yes, than is an option but it requires to compile 2 packages on the production Server so its on hold for now. The other problem is that it is time based, like tail (File::Tail uses Time::Hires) but I really dont know if it is possible to read logs for new input other than time waiting.
      Best Regards,
      Nuno A
        File::Tail needs to be built, yes, but there's no compile involved.

        Time::HiRes is included with perl5.8.0 and up. If you are on an older perl, you can try just commenting out the use Time::HiRes line in File::Tail. Then it will use the normal time() and sleep() functions that don't have subsecond granularity.

        I'm not sure what you are proposing to do other than time waiting...File::Tail tries to pick a reasonable wait period, and you can specify a maximum interval. You can even specify a maxinterval of "0 but true" if you really don't want to wait, but that sounds like a bad idea to me. (Haven't actually tried it, but looking at the code, I think it will work.)