while statement to read input : While « Statement « Perl






while statement to read input

    

#!/bin/perl
while(<>){
    ($name, $phone)=split(/:/);
    unless($name eq "barbara"){
        $record="$name\t$phone";
        print "$record";
    }
}
print "\n$name has moved from this district.\n";

   
    
    
    
  








Related examples in the same category

1.A program that demonstrates the while statement.
2.A program that loops using a single-line conditional statement.
3.A while loop is often used to read from a file until there is no more data available.
4.Analysis of sales results
5.Average-sales problem with counter-controlled repetition
6.Conditional operator: The unless Modifier and while loop and __DATA__
7.Count 10 with while loop
8.Loop with label
9.Looping Modifiers: The while Modifier
10.Looping While
11.The while Loop
12.The while command
13.The while, until, and do Statements
14.Use while loop to read console input
15.Use while loop to read console input and replace
16.Using while and for statement to check if you had typed in four letter words
17.Using while loop to calculate the number of lines in a file
18.Using while loop with each
19.Using while statement to check the entered value from keyboard
20.Using while statement to read from keyboard
21.While loop and counter
22.While loop counter
23.While statement and scalar control value
24.while and until loop
25.while data section
26.while/until Loop
27.Using While loop the output the elements in an array