For loop





The for statement is another way your Perl program can execute a block of statements say a number of times, based on the value of an expression. The syntax of a for loop is quite a bit different from that of while and until loops. For example, here is a for loop to add the numbers from 1 to 10:
You have to use the braces around the statement block even if there are no statements within braces. For example, you can write a for loop to add the numbers from 1 to 10 using an empty statement block, as follows:
for ($i=l, $sum=0; $i <10; $sum += $i, $i++)
Domain Name Search
|