while

while performs a block of statements as long as a particular condition is true:

while ($x<10) {     print "$x\n";     $x++;}

Remember that the condition can be anything that returns a true or false value. For example, it could be a function call:

while ( InvalidPassword($user, $password) )        {        print "You've entered an invalid password. Please try again.\n";        $password = GetPassword;}

Get Ubuntu Unleashed 2013 Edition: Covering 12.10 and 13.04, Eighth Edition 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.