in reply to Re: append values to a same key in hash
in thread append values to a same key in hash

Just be aware that exists($h{a}->{b}) will autovivify the first hash key component ({a}):

use strict; use warnings; my %h; unless (exists($h{foo}{bar})) { print "\$h{foo}{bar} exists: no\n"; print "\$h{foo} exists: ", exists($h{foo})?'yes':'no', "\n"; } #outputs # $h{foo}{bar} exists: no # $h{foo} exists: yes

If you want to be extra careful not to create hash keys, you'll have to use if (exists($h{a} and exists($h{a}->{b}) instead. and (or &&) short circuits so you'll never reach the second test if the first part of the key is non-existent.

Best, beth