yueli711 has asked for the wisdom of the Perl Monks concerning the following question:
Hello, Below is the program to calculate average value. I really do not understand why the value of "count" will change. Thanks in advance!
use strict; use warnings; sub total { my $sum; foreach (@_){ $sum += $_; } $sum; } sub average { if (@_==0){return} my $count=@_; my $sum =total(@_); $sum/$count; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: why the value of count will be change?
by toolic (Bishop) on May 09, 2018 at 00:25 UTC | |
by yueli711 (Sexton) on May 09, 2018 at 11:53 UTC | |
Re: why the value of count will be change?
by LanX (Saint) on May 08, 2018 at 23:51 UTC | |
by yueli711 (Sexton) on May 09, 2018 at 00:06 UTC | |
by LanX (Saint) on May 09, 2018 at 00:09 UTC | |
Re: why the value of count will be change?
by Marshall (Canon) on May 09, 2018 at 01:39 UTC |
Back to
Seekers of Perl Wisdom