Using "until" and "do..until" for looping.

วันจันทร์ที่ 14 กันยายน พ.ศ. 2552

- "until" is looping statement for condition is false. Value opposite while.

$a = 0;

until ($a <0) (

print $ a. ",";

$a--;

)

# 0 will be displayed, because when set to $a = 0 then the check is if the conditions $a <0 to undo the block command. So if $a = 0 is a blog command until the display value from the variable $a after that $a will be reduced up to 1 value, so $a = -1 and the Blue of the year to check conditions again. Will be real terms. When conditions are true. Is the cross-block command in a command Lou year to another.

- do ... until the check until the conditions are similar to the instructions on the blog when conditions are false. And it will work like the do ... while in the first round to take command in a do ... until then check conditions before.

$ a = -1;

do (.

print $ a. ",";

$ a -;

) Until ($ a <0);

# Values are expressed -1, 0.

0 ความคิดเห็น:

แสดงความคิดเห็น

 
 
 
 
Copyright © Basic Perl