How to iterate through Hash (of Hashes) in Perl?

后端 未结 9 875
無奈伤痛
無奈伤痛 2020-12-08 03:20

I have Hash where values of keys are other Hashes.

Example: {\'key\' => {\'key2\' => {\'key3\' => \'value\'}}}

How can I iterate throug

9条回答
  •  庸人自扰
    2020-12-08 03:52

    The earlier answers show how to roll your own solution, which is good to do at least once so you understand the guts of how perl references and data structures work. You should definitely take a read through perldoc perldsc and perldoc perlref if you haven't already.

    However, you don't need to write your own solution -- there is already a module on CPAN which will iterate through arbitrarily-complex data structures for you: Data::Visitor.

提交回复
热议问题