For Statement in Perl
by Geethalakshmi[ Edit ] 2010-09-17 14:06:20
For Statement in Perl
The for statement performs a loop as long as a a tested expression is true, increasing the value for each loop.
for ( initial_expression; test_expression; increment_expression ) {
statement1;
statement2;
}
The following example prints the numbers 1 to 10.
for ($i = 1; $i <=10; $i++) {
print "$i ";
}