in reply to Thread to read a file every second
I got my info on threading from: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); }
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 | |
by PodMaster (Abbot) on Oct 06, 2004 at 10:10 UTC |