#! perl -slw use strict; use Data::Dump qw[ pp ]; sub dumpIt { my $r = shift; my $d = shift() // 1; die "'$r' not a hashref" unless ref $r eq 'HASH'; print "{" if $d == 1; for( keys %$r ) { if( ref $r->{ $_ } ) { print chr(9) x $d, "$_ => {"; dumpIt( $r->{ $_ }, $d + 1 ); print chr(9) x $d, "}"; } else { print chr(9) x $d, "$_ => $r->{ $_ }"; } } print "}" if $d == 1; } my %multiLevelHash = ( 'firstSampleKey' => 'SampleValue', 'secondSampleKey' => { 'secondLevelSampleKey' => { 'thirdLevelSampleKeyOne' => 'thirdLevelSampleValue', 'thirdLevelSampleKeyTwo' => 'thirdLevelSampleValue', 'thirdLevelSampleKeyThree' => { 'fourthLevelSampleKey' => 'fourthLevelSampleValue', } } } ); dumpIt( \%multiLevelHash ); __END__ C:\test>junk90 { firstSampleKey => SampleValue secondSampleKey => { secondLevelSampleKey => { thirdLevelSampleKeyTwo => thirdLevelSampleValu +e thirdLevelSampleKeyThree => { fourthLevelSampleKey => fourthLevelSam +pleValue } thirdLevelSampleKeyOne => thirdLevelSampleValu +e } } }
In reply to Re: How to print a multi-level Hashes of Hashes without the use of a module
by BrowserUk
in thread How to print a multi-level Hashes of Hashes and extract parts of it
by thanos1983
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |