You can use a for loop to loop for a specific number of times. : For « Statement « Perl






You can use a for loop to loop for a specific number of times.

    

#for (initialization; expression; continue) {
#    # ...
#}


#!/usr/bin/perl -w

for ($i = 0; $i < 10; $i++) {
   print "Iteration $i.\n";
}

   
    
    
    
  








Related examples in the same category

1.A program that prints the numbers from 1 to 5 using the for statement.
2.Create an infinite loop using a for loop:
3.Here is an example of the for loop
4.Initialization, test, and increment, decrement of counters is done in one step
5.Loop Control Statements
6.Looping through an array with the for repetition structure
7.Nested for loop
8.Put more than one statement first and third part of for statement
9.Reference array length in for loop
10.Reference for loop control variable
11.Standard for structure: Loops 5 times, printing the multiples of 5 from 0-20
12.Sums the numbers from 1 to a specified number and also sums the even numbers.
13.The for Loop
14.The or part allows for a statement to be executed if the main part fails.
15.Use for loop to output all elements in an array
16.Use for loop to output the element one by one in an array
17.Uses the for statement to read four input lines and write three of them.
18.Using block labels with next.
19.Using for loop to sum the total
20.Using my inside for statement
21.Using nested for loop to assign value to two dimensional array
22.Using nested for loop to output the elements in a two-dimensional array
23.Mixed diamond operator with for loop condition
24.Mixed diamond operator with for loop condition 2