start of tree ------------------ Da | something > 1234: 1 (81.06/25.89) Number of Items : 15 Size of the Store : 30 something else here === Summary Matrix === a b <-- classified as 11111 222 | a = 0 3333 444 | b = 1 #### start of tree ------------------ Da | something > 456: 1 (48.07/89.21) Number of Items : 50 Size of the Store : 100 something else here === Summary Matrix === a b <-- classified as 55555 666 | a = 0 7777 888 | b = 1 #### filename aa ba ab bb no_of_items size_of_store file1 11111 222 3333 444 15 30 file2 55555 666 7777 888 50 100 etc... (for extra files) #### $resFolder = Somelocation; # defined in other part of the code @files = glob($resFolder ."/". "t-*.csv"); $numFiles = scalar(@files); $ResSummaryFile = $resFolder .'/' . 'ResSummary' . '.csv'; @header = ("filename","aa","ba","ab","bb","#_of_items","size_of_store"); my @tempReadOuts; ##loop through file list to extract necessary data (results): for ($i = 0; $i < $numFiles; $i++) { open(FH1, $files[$i]); print "Processing file... $files[$i]\n"; $tempReadOuts[0]=$files[$i]; open(FH2, ">$ResSummaryFile"); while () { chomp; @this_line = split("\n", $_); for ($j = 0; $j < scalar(@this_line); $j++) { ## code to extract syntaxes should go here; } print FH2 "@tempReadOuts/n"; } close(FH1); close(FH2);