Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hello dear Monks!
I am again stuck because I am supposed to answer the following question without using the <> operator.
The question is, given a file with numbers, and using the while loop, how can you sum up the values that are in the file?
Of course the easy way would be something like:
Any more "primitive" way for this?
I am again stuck because I am supposed to answer the following question without using the <> operator.
The question is, given a file with numbers, and using the while loop, how can you sum up the values that are in the file?
Of course the easy way would be something like:
$count=0; while(<>) { $mynumber = $_; chomp $mynumber; $count +=$mynumber; } print $count;
Any more "primitive" way for this?
|
---|
Back to
Seekers of Perl Wisdom