The PERFORM statement transfers control to one or more procedures and returns control implicitly when the sequence completes. PERFORM can also be used for inline loops withing the scope of the PERFORM.
VARYING phrase allows for nesting with one or more
AFTER clauses, and the conditional test can be
BEFORE (default) or
AFTER each loop.
THRU clause of a procedural perform assumes sequential top down control flow from
procedure-1 through the end of
procedure-2. THRU is a contentious issue, and many programmers prefer
SECTION rather than using
THRU paragraphs. Some shops may mandate
PERFORM THRU with an explicit exit point paragraph, others may ban the use of
THRU finding it more difficult to debug.
PERFORM VARYING TALLY FROM 1 BY 1 UNTIL TALLY > 5 DISPLAY TALLY END-PERFORM