my ( $intotal, $outtotal, $i ); foreach my $value ( @{ $data } ) { $start += $step; my ( $minute, $hour, $day, $month, $year ) = ( localtime( $start ) )[ 1, 2, 3, 4, 5 ]; $month += 1; # Why does localtime give month -1? my $dt = DateTime->new( year => $year, month => $month, day => $day, hour => $hour, minute => $minute ); next unless $span_set->contains( $dt ); $i++; $in_total += $value->[ 0 ]; $out_total += $value->[ 1 ]; } # Now go off and work out averages / percentages etc... # Build a HoH and exit the for loop. } # Output some purty HTML.