#5# .... push (@allsents, "MATCH #$count $sentmatches[$m]") unless $seens{ $sentmatches[$m] }++; $count++; } } push (@sepmatches, @allsents); ##$allmatches[0] is header, [1] is all sentences etc. EVEN - header, ODD - sent ## Now join headers and sentences (0 and 1 etc.) foreach (@sepmatches) { ##Try Use natatime where n=2 $joinmatches = join ('', @sepmatches); } push (@allmatches, $joinmatches); @sortedallmatches = sort {length $b cmp length $a} @allmatches; } } } print @sortedallmatches; }