in reply to Brain muchly befuddled by nested hashes

'$day'
Variables don't interpolate in single quotes. That should be "$day", or better, just $day.
$ClubTotal{ 'DayOfMonth'=> $date }
What are the keys of the outermost hash supposed to be? That may not do what you intend. When you provide a list when referencing a hash element, perl assumes you are using old perl4-style emulated nested hashes and produces a single hash key like this: $ClubTotal{"DayOfMonth$;$date"}. See $;.
Data::Dumper produces:
Sadly, Data::Dumper doesn't have the best defaults, so it is producing literal \034 characters in the output there. Always setting $Data::Dumper::Useqq=1 when examining your data can be helpful.

Replies are listed 'Best First'.
Re^2: Brain muchly befuddled by nested hashes
by graff (Chancellor) on Nov 24, 2008 at 05:30 UTC
    When you provide a list when referencing a hash element, perl assumes you are using old perl4-style emulated nested hashes and produces a single hash key like this: $ClubTotal{"DayOfMonth$;$date"}.

    Based on looking at the OP's output from Data::Dumper (and on trying it myself), it seems that perl is not adding any sort of field delimiter in the hash key:

    perl -le '$n=0; $h{"foo"=>$n++}=$n for (0..3); print "$_ => $h{$_}" fo +r (sort keys %h)' foo0 => 1 foo1 => 2 foo2 => 3 foo3 => 4
    That said, I would agree that presence of the "fat comma" (=>) as part of the hash-key expression looks like a misunderstanding (and/or could be misunderstood by less skilled readers), and is rather ugly as well. Something like simple concatenation or string interpolation would be clearer ($hash{'string'.$num} or $hash{"string$num"}).
      The delimiter is there, you just don't see it. Hence my comments about Data::Dumper's defaults (added shortly after I first posted, so you may have missed them).
      $ perl -le '$n=0; $h{"foo"=>$n++}=$n for (0..3); use Data::Dumper; pri +nt Dumper \%h; $Data::Dumper::Useqq=1; print Dumper \%h' $VAR1 = { 'foo1' => 2, 'foo0' => 1, 'foo2' => 3, 'foo3' => 4 }; $VAR1 = { "foo\0341" => 2, "foo\0340" => 1, "foo\0342" => 3, "foo\0343" => 4 };