in reply to Dynamically naming and creating hashes
i'd like to stick with only one hash and it's key/values
Can you explain what's important about that to you? I'm surprised that you don't find the hash of hashes to be an easier and more versatile approach. Unlike the array of hashes or even array of names, a hash of hashes lets you use either the values or the keys, depending on whether you want to work with the hashes directly or with the names:
my %hashes = map { $_ => {} } qw( testA testB testC ); # by hash my $i=0; $_->{'key'} = $i++ for values %hashes; # by name $hashes{$_}{'name'} = $_ for keys %hashes;
-xdg
Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
|
|---|