Uses the for statement to read four input lines and write three of them. : For « Statement « Perl






Uses the for statement to read four input lines and write three of them.

    

#!/usr/local/bin/perl 

for ($line = <STDIN>, $count = 1; $count <= 3; $line = <STDIN>, $count++) { 
   print ($line); 
} 

   
    
    
    
  








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.Using block labels with next.
18.Using for loop to sum the total
19.Using my inside for statement
20.Using nested for loop to assign value to two dimensional array
21.Using nested for loop to output the elements in a two-dimensional array
22.You can use a for loop to loop for a specific number of times.
23.Mixed diamond operator with for loop condition
24.Mixed diamond operator with for loop condition 2