in reply to push onto hash!
You don't normally need to initialize (autovivification will take care of this) but you can use the ||= construction:
for (@somelist) { my($foo,$bar) = split; my $x = somecalc($foo,$bar); $somehash{ $foo }->{ $bar } ||= []; push @{ $somehash{ $foo }->{ $bar } }, $x; }
||= basically says 'if the left-hand value isn't defined, assign the right-hand side to it'.
Chris
M-x auto-bs-mode
|
|---|