Part 3 in our continuing series on the popular scripting language, Perl. This week's article teaches you more about Perl's controlstructures - including the FOR and WHILE loops - and also introduces you toPerl's array variables.
Now that you know all about Perl's control structures, you're probablywondering which one to use when. Well, this section will try to clear thatdilemma up for you.
* If you have a set of statements that need to be executed a number oftimes until a certain condition is met, but you have no idea what thatnumber is, the "while" and "until" loops are a good bet.
* If you have a set of statements that need to be executed at least once,the "do-while" and "do-until" loops are the ones to go with.
* If you need to execute a set of statements a specific number of times,pick the "for" loop and don't think twice!
* If you need to process every element of an array, go with the "foreach"loop.
Next time, we'll be teaching you a little more about array variables, andsome of Perl's more interesting array functions; we'll also take a look atPerl's file manipulation capabilities.
What will you do until then? Well, they're bound to be showing re-runs of"Friends" on your local cable channel...
This article copyright Melonfire 2000. All rights reserved.