Control Flow Constructs

Like any modern programming language, Perl has a wide variety of control flow constructs. They are typically subdivided into looping constructs and decision-making constructs.

Decision-Making Constructs

Decision-making constructions in Perl center around various if constructs. There is also an unless construct whose main appeal is in error checking.

IF

Decisions in Perl are made with the keyword if. Depending upon the particular logic of the program, there may also be an else portion to go along with the if. In the simple example shown here, the opening and closing curly braces are necessary even in the case where there is only one statement in the body of either the if or the else portion. The tested expression is either ...

Get Programming PERL in the .NET Environment now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.