# Figure out the first timestamp foreach my $bar (sort keys %master) { $j = $bar; last; } # Figure out the last timestamp foreach my $bar (reverse sort keys %master) { $l = $bar; last; } do { my $out; $out .= "$j,"; $out .= $master{$j}{'CCMT'} || '0'; $out .= ","; $out .= $master{$j}{'CCOA'} || '0'; $out .= ","; $out .= $master{$j}{'CDEC'} || '0'; $out .= ","; $out .= $master{$j}{'CFST'} || '0'; $out .= ","; $out .= $master{$j}{'CREF'} || '0'; $out .= ","; $out .= $master{$j}{'CRSP'} || '0'; $out .= ","; $out .= $master{$j}{'CVEH'} || '0'; $out .= "\n"; print $out; $j += 60; } while $j <= $l;