sub get_avr { my ($cluster) = @_; open(IN, "$outputfile"); while () { foreach my $hour (0 .. 23){ $_ =~ tr/ //s; ($date,$time,$cpu{$hour},$io,$rate,$mem) = split(/ /, $_); if ($time =~ /$hour:00/){ $tmem{$hour} = ($tmem{$hour} + $cpu{$hour}); $cnt{$time}++; $avr{$hour} = ($tmem{$hour} / $cnt{$time}); print "$cluster $time $avr{$hour}\n"; } } } }