in reply to Dynamically creating a hash based on a variable
It's better to use a hash-of-hashes instead:
See also perlreftut and perldata.# set up the base hash my %hashes = (); # in the loop: my $date = $4.$3.$2; if (my $hashref = $hashes{$date}) { print "<TD class=table_font>$date - Hash exists</TD>\n"; # play with hash } else { my $hashref = {}; # create a new empty hash $hashes{$date} = $hashref; store the hashref in the main hash print "<TD class=table_font>$date - Hash doesn't exist</TD>\n"; # play with hash }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Dynamically creating a hash based on a variable
by beethamd (Initiate) on Apr 15, 2007 at 14:02 UTC |