my $hash={}; while (have_records){ my $time = (date_from_record) . "-" . (time_from_record); if ( ! defined($hash->{$time} ) { $hash->{$time} = { min => SOME_VERY_LARGE_NUMBER, max => 0 } } $hash->{$time}->{min} = ( (VALUE_FROM_RECORD) < $hash->{$time}->{min} ? (VALUE_FROM_RECORD) : $hash->{$time}->{min} ) ; $hash->{$time}->{max} = ( (VALUE_FROM_RECORD) > $hash->{$time}->{max} ? (VALUE_FROM_RECORD) : $hash->{$time}->{max} ) ; } # NOTE: change (date_from_record), (have_records and other # psuedo-values to things that are reasonable.