sub processfile { my ($file, $list) = @_; my $script = "/export/home/limo/Perl/exfields.pl -e"; my %hash; # no need for @list for my $arg (split /,/ => $list) { open(FILE, "$script $arg $file |") or die "System error: $!\n"; while () { # did you mean /^(#|none|unkno)/ ? next if /^#|none|unkno/i; chomp; $hash{$arg} = [split]; # or, if there'll be another $arg of the same value.. # push @{ $hash{$arg} }, split; } close FILE; } # consider return a REFERENCE to the hash... # it might be more memory-effective return %hash; }