跳转至内容

Perl 编程/练习 8

来自维基教科书,开放世界观开放书籍

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");
华夏公益教科书