Perl Programming/Exercise 8

From Wikibooks, open books for an open world
< Perl Programming
Jump to: navigation, search

PROGRAM FOR COUNTING THE NO: OF ENTRIES AND THE TOTAL

#!/usr/bin/perl



$total = 0;

$count = 0;

do {

       print ("Enter a number 0 to quit : ");

       $value = <>;

       chomp ($value);

       $total = $total + $value;

       if ($value != 0) {$count++;}

} while ($value != 0);



print ("\nNumber of entries : $count");

print ("\nTotal             : $total\n");