use strict; use warnings; use MCE::Loop; use MCE::Shared; my @dirs = qw( a b c d e f ); my %hash = map { $_ => MCE::Shared->hash } @dirs; MCE::Loop->init( max_workers => $#dirs, chunk_size => 1 ); mce_loop { my $dir = $_; proccess_1_file($dir, "syn.log") if (-e "$dir/syn.log"); } @dirs; print $hash{"a"}{"area"}, "\n"; sub proccess_1_file { my ($dir, $file) = @_; open(my $fh, "$dir/$file") or die "cannot open $dir/$file $!"; while (<$fh>) { chomp; if ($_ =~ /^area=(.*)/) { $hash{"$dir"}{"area"} = $1; } } }