in reply to Script for MAX and Min

Why bother doing all that work when someone else has already done it for you? I think you'll find the List::Util module in the Scalar-List-Utils bundle will do all you want.

use List::Util; # assume data in @data my $max = max @data; my $min = min @data; my $sum = reduce { $a + $b } @data; my $avg = $sum / @data;

Blessed Be
The Pixel