my $file_number = 0; # loop through all file-handles foreach my $file (@files) { # open the file open(my $fh, '<', $file) or croak "Unable to open file: $file"; # count this file as being processed ++$file_number; # give the user a little bit of an update print "Now processing file $file_number\n"; # completely process the file while (<$fh>) { # trim leading/trailing whitespace s/^\s+//; s/\s+$//; # tab-delimited rows with the stats value in the last column my @row = split("\t"); my $val = pop(@row); # sort the row and concatenate it into a key @row = sort(@row); my $key = join("\t", @row); # skip rows with missing values next() if (scalar(@row) != $subset_num); # save this data point push @{ $data{$key} }, $val; } # look for any missing values foreach my $key (keys(%data)) { if ($file_number > scalar( @{ $data{$key} } )) { push @{ $data{$key} }, ''; } } # close the filehandle close($fh); }