Perl Programming Page 3 - Perl 101 (Part 3) - Looping The Loop |
The not-so-distant cousin of Perl's "while" loop is its "until" loop, whichlooks like this: To illustrate the relationship between the "while" and "until" loops, readthese two sentences: WHILE you're less than twenty-one years of age, you can't drink! UNTIL you're over twenty-one years of age, you can't drink! In other words, the conditional expression to be evaluated in a "while"loop will be exactly the opposite of the one to be evaluated in an "until"loop. So take another look at the WEEP, which we've rewritten using an"until" statement: If you compare the "while" and "until" lines in the WEEP examples above,you'll see that the two conditional expressions are exactly the opposite ofeach other. And if you can't decide which one to use, try this little trick- translate your "until" or "while" statement into English, roll it aroundyour tongue, and see if it sounds right to you... This article copyright Melonfire 2000. All rights reserved.
blog comments powered by Disqus |