in reply to Thread to read a file every second

Neither have I, and my version of Perl doesn't support threading, but here's some code that might work:
use threads; use strict; my @fpaths = ('fpath1', 'fpath2'); my %fdata; foreach (@fpaths) { my $data; my $child = threads->new(\&check_file, $_, $fdata{$_} = \$data); } sub check_file { my ($fpath, $arrp) = @_; my $handle; while (!-e $fpath || !open($handle, $fpath)) { sleep(1); } $$arrp = join('', <$handle>); close($handle); }
I got my info on threading from:

http://migo.sixbit.org/papers/Perl_Threads/slide-index.html

Replies are listed 'Best First'.
Re^2: Thread to read a file every second
by TedPride (Priest) on Oct 06, 2004 at 09:38 UTC
    Totally unrelated, how did my first post manage to show up underneath my second post?
      It didn't. This is called a threaded view (parent/child). By default its chronological. Example
      perlquestion - 1st reply to perlquestion - 1st reply to 1st reply to perlquestion - 2nd reply to perlquestion - 1st reply to 2nd reply to perlquestion - reply 3 - reply 4
      It doesn't matter if 1st reply to 1st reply to perlquestion got created after 2nd reply to perlquestion, its not a reply to perlquestion.

      MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
      I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
      ** The third rule of perl club is a statement of fact: pod is sexy.