in reply to Code Review! Go Ahead, Rip It Up!
reads better.foreach ( @_ ) { push @differences, $_ - $mean; }
In the fragment
you use $standard for two semantically different (though related) purposes. Having variables that mean two (or more) different things within a subroutine can get you into trouble later (say, when you pick up the code a couple of months from now). You can eliminate this problem by writingmy $standard = 0; for (@differences) { $standard = $standard + $_; } $standard = sqrt($standard/$sample_size); return $standard;
my $sum_diff = 0; map { $sum_diff += $_ } @differences; return sqrt($sum_diff / $sample_size);
You might also consider using 4 spaces for indentation.
And at some point, somebody is going to pass an empty list...
|
|---|