# read in lines across 20 files while (1) { my $batch1 = ; chomp($batch1); last unless ($batch1); ... my $batch20 = ; chomp($batch4); # put the lines into an array # @batch_lines has 20 elements push(@batch_lines, $batch1); ... push(@batch_lines, $batch20); #init the 2-array @confidence_mtx after parsing out some #data for the # batch_lines elements foreach (@batch_lines) { next if /^Probeset/; my ($probe, $tmp) = split /\t/; push (@confidence_mtx, [ split /,/ , $tmp ]); } # do some lookups in the confidence_mtx data structure my $batchnumber = $sample2batch{$consensus_sample_batch}; my $offset = $sample2offset{$consensus_samples_offset}; if ( $confidence_mtx[$batchnumber-1][$offset-1] > $CONFIDENCE_CUTOFF) { $consensus_genotypes[$i] = '00'; } undef @confidence_mtx; } # close while(1) loop