in reply to help finding mean, numbers above and below mean from an exponential distribution
so the condition for entering the while loop is $k>=2 but inside the loop itself someone might guess that you're checking if $k==1 and it may not become clear that there's a decrement towards the while block end, for readability and logic flow it would be better if this is written down towards the end of the while block after $k=$k-1; for example, but again, since you don't want $k==1 to be considered the loop would exit automatically if you only write while($k>2) without the need to check if $k has reached to 1.while ($k>=2) { if ($k==1) {last;}
compare:
while($k>2){ $k=$k-1; print "$k\n"; } #and while($k>=2){ $k=$k-1; #last if $k==1; print "$k\n"; }
$total=0; is used only once, what is it intended to contain?, where @first is coming from in $ntotal+=$_ for @first;
Another major point, using strictures can save you a lot of nasty repercussions arising from undiscovered bugs and for readability you may want to pick up an indentation that is intuitive or use Perltidy, here is an initial tutorial.
|
|---|