use List::Util qw( sum ); @averages = (); push(@averages, int(sum(@$_)/@$_)) foreach 0..@scores;