The various if statements in Perl are all used to control execution by branching to differ-ent parts of a script. The second way to control execution is through the use of a loop, where the same block of Perl statements are executed repeatedly, stopping only when some condition is met. Perl has two general sets of loops, both of which do roughly the same thing: while loops, which loop until a condition is met, and for loops, which loop a certain number of times. Generally, whiles can be rewritten to emulate fors, and vice versa, but conceptually each one seems to lend itself to specific situations better than the other.
We'll start with the while loops, of which Perl has three: while, do…while, and until.
You've already seen ...