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); }