Finally, we come to conditionals and loops! You've already learned a fair amount about the more popular conditional, if, and about while loops, so you might have already deduced that conditionals and loops are used to control the execution of blocks of statements in Perl script. Without these structures, your script would run from top to bottom, executing each statement in turn until it got to the end. No testing to see if a value is true, and then branching to a different bit of code; no repeating the execution of a block of statements a number of times. Scripts would be very boring indeed without conditionals and loops. They're so important you had to actually start learning about them two days ago, before we even got to this lesson.
In this lesson, we'll discuss in detail the various conditional and loop constructs you have to work with in Perl, including
An introduction to block statements
The if and if…else, if…elsif, and unless… conditionals
The while, do…while, and until loops
The foreach and for loops
Controlling loops with next, last, redo, and labels
In addition, we'll also look at a two other topics that will build on your Perl knowledge, including
Using $_ (the default variable) as a shortcut for many operations
Reading input from files with <>