use strict; use warnings; use MCE::Hobo; use MCE::Shared; my @dirs = qw( a b c d e f ); my %hash = map { $_ => MCE::Shared->hash } @dirs; foreach my $dir (@dirs) { if (-e "$dir/syn.log") { MCE::Hobo->create(\&process_1_file, $dir, "syn.log"); } } MCE::Hobo->waitall; print $hash{"a"}{"area"}, "\n"; sub process_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; } } }