On Sat, 30 Jul 2005 14:11:58 -0400, Ronald J Kimball wrote: >Why do you say it erases all previous keys in the hash?
Because I tried it. Or so I thought. Clearly I must have got mixed up in my multiple tests in the wee hours. - - #!/usr/local/bin/perl -w # test growing array of hashes use strict; $\ = "\n"; my %H = (); my $ip = '64.207.97.183'; $H{$ip}[0] = {'nam1','','nam2','','nam3',''}; printk(); $H{$ip}[0]{nam4} = ''; # add one key printk(); sub printk {local $" = ', '; @_ = sort keys %{$H{$ip}[0]}; print "names: @_"; } __END__ names: nam1, nam2, nam3 names: nam1, nam2, nam3, nam4 - - Then the problem is gone. Thanks a lot for the correction. - - On Sat, 30 Jul 2005 14:11:58 -0400, Ronald J Kimball wrote: > but I don't know a way to grow a hash within an array, such as: > > $H{$ip}[0]{$nam4}=''; or > $H{$ip}[0]={$nam4,''}; > > Both constructions erase all previous keys in the hash. Is there another way ? The second one replaces the entire hash, of course, but the first one works fine. Why do you say it erases all previous keys in the hash? There is no difference between a hash within a hash and a hash within an array.