in reply to Brain muchly befuddled by nested hashes

Your date format is not suitable for sorting. It should be in YYYY/MM/DD format and not DD/MM/YYYY. From your code a date 10/10/2008 comes first compared to 09/09/2000. In addition, the sort function is not by default a numeric sort, which is what you want. If you try to sort the array (2,10) then you will get (10,2). You should reconsider also, the way you build up the hash: the => seems irrelevant in the outer hash.

Replies are listed 'Best First'.
Re^2: Brain muchly befuddled by nested hashes
by WartHog369 (Novice) on Nov 24, 2008 at 17:35 UTC

    Thank you - ptoulis (Sexton) from Nov 24, 2008 at 08:28 UTC - for your quick reply to my inquiry and your most helpful suggestions.

    I recall now, I have previously read about sorting dates in century/mm/dd order instead of the traditional American date structure of dd/mm/yy.

    However, if you will please note: After I parse the 'incoming' date structure into its' individual components - I do not deal with either format - in any manner - in the program. You will further note that in the line:
    if (($ampm eq "a") && ($hour <= 9)) {$hour = '0'.int($hour) ; }
    that I prepend a zero to the single digit hour to assist in sorting.

    Could you, please, expand on your comment: "You should reconsider also, the way you build up the hash: the => seems irrelevant in the outer hash."
    I have tried to mimic the example from the manpage: "perldsc", which shows:

    %HoH = ( flintstones => { lead => "fred", pal => "barney", }, jetsons => { lead => "george", wife => "jane", "his boy" => "elroy", }, simpsons => { lead => "homer", wife => "marge", kid => "bart", }, );

    What am I missing (doing wrong)?
    Again, thank you for your assistance, sometimes it's a chore trying to teach an old dog new tricks.
    Thomas

      Even if you prepend the '0' before values, it still isn't enough. For example 2000<2008 but 10/2000>08/2008, so it is right to check big things first.

      About the hashes, my point was that the usual case is that you define a hash as %hash = (key1=>value1, key2=>value2...); and it is not frequent (if plausible) to use the => symbol inside the key definition. You say $ClubTotal{'DayOfMonth'=>$date}{..} =... which puts the '=>' in the key. Now, the hash concept is that a hash is just a table organized by distinct words. As such, there is no point in prefixing the 'DayOfMonth' (a constant string before the date) and the '=>' is really misleading because one expects a value after it. It would be much more readable to write something like this:
      %ClubTotal = { $date => { TotalPerDay=>1, HourSignIn=> { Value=>$hour, ToPerlHour=>$perlHour } } }

      This is just an example. Things should be as simple as possible. For example, in your code you say: $ClubTotal{ 'DayOfMonth'=> $date }{'Date'} = $date ;, which means that your key and value are the same variable! There are 3 date's in this code which is a waste of time (and space). Simply stating $ClubTotal{$date}=... is enough since the date you want is the key of the hash.