use warnings; is always.
Your
my %hash = {'inner1'=>{'foo'=>5},
'inner2'=>{'bar'=>6}};
wrong; {}generates an anonymous hash link, and% hash gets one key (this hash link is gated) and the value is undef.
You wanted:
my %hash = ('inner1'=>{'foo'=>5},
'inner2'=>{'bar'=>6});
Regarding the transition to routines, you cannot pass hashes; the code, as you show, aligns the hash in the list, and then collects the hash from again @_, but it will be a separate copy. If you really want to use the same hash, you must pass the hash link instead.
source
share