I think what you are missing here is that the values in a hash (or in an array or in a scalar) can be references. This I think makes what you call generic type. And you don't have to create the same keys in all of them, you can just use them.
So the structure you are looking for is either a hash of hashes, or more likely an array of hashes. You would just create a hash for each row, and push a reference to it into the array:
my @database; # loading the db while( my %row= get_a_row()) { push @database, \%row; } # put the row in the db # printing the results # first the keys my $row1= $database[0]; # I assume there is at least 1 row # and thet all rows have the same keys my @keys= keys %$row1; # %$row1 returns the hash referenced by $row1 print join( "\t", @keys), "\n"; # or however you want to print them # print the values, tab separated, 1 row/line foreach my $row (@database) { print join( "\t", values %$row), "\n"; } # same as with keys, just + more concise }
(untested code)
In reply to Re: "Generic" variables/Hash of hashes
by mirod
in thread "Generic" variables/Hash of hashes
by New Novice
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |