It's just a cut down version of the real script, that's why there are no strict or warnings.
But anyhow. The ELSE part of the outermost is only to review the section saved and if the value is found in the section then do the output.
The script is supposed to look at each line, starting with t and until it reaches T and save all that into @section.
When it finds T it goes to the start with $newsection = 1 and then goes to ELSE to check if the section should be saved.
It then clears the @section array and goes to the start of the loop.
But why it only checks the ^t at start I don't known, and it doesn't seem to matter if I put it second as an elsif.
I am convinced now that everytime the section is reset and the loop starts to write into the array the first iteration is lost.