Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Sort Hash array using date

by jethro (Monsignor)
on Jan 15, 2009 at 17:14 UTC ( [id://736594] : note . print w/replies, xml ) Need Help??


in reply to Sort Hash array using date

Your program works exactly as expected, I didn't change anything except for the initalization to test your code:

#!/usr/bin/perl use warnings; use strict; my %Date_Time = ( "05-12-2008" =>{ 0 => { 5 => {9 => 1}}} , "03-12-2008" =>{ 2 => { 8 => {5 => 1}}} , "04-12-2008" =>{ 0 => { 5 => {8 => 1}}} ); #$dateOut = "$oDay".'-'."$oMon".'-'."$oYear"; #print"Date out => $dateOut\n"; #$Date_Time{$dateOut}{$dSec}{$dMin}{$dHour} = 1; #Retrieving the hash array output foreach my $date ( sort keys %Date_Time ) { #print"Date=> $date\n"; foreach my $sec (sort keys %{$Date_Time{$date}}) { #print"Seconds=> $sec\n"; foreach my $minute (sort keys %{$Date_Time{$date}{$sec}}) +{ #print"Minute=> $minute\n"; foreach my $ hour (sort keys %{$Date_Time{$date}{$sec} +{$minute}}) { print"Date=>[$date] --> [$hour]:[$minute]:[$sec]\n +"; } } } } output: Date=>[03-12-2008] --> [5]:[8]:[2] Date=>[04-12-2008] --> [8]:[5]:[0] Date=>[05-12-2008] --> [9]:[5]:[0]