in reply to Filling value of nested hash
Since you are dealing with an object of unknown depth, a recursive parser is likely easiest. Maybe something like
#!/usr/bin/perl use strict; use warnings; my $VAR1 = { 'File_Handler' => { 'Compile_File' => undef, 'Log_Details' => undef, 'Complete_Logging' => undef, 'Get_Config' => undef, 'Get_Data' => undef, 'Get_Abc_Data' => undef, 'Internal_Operations' => { 'Get_Abc_Data' => + undef, 'Start_Operations +' => undef, 'Get_Start_Up_Dat +a' => undef, 'Construct_Failur +e_Ident' => undef, 'Construct_Additi +onal_Words' => undef, }, 'Start_File_Handler' => undef } }; sub output_files { my $path = shift; my %hash = @_; for my $key (keys %hash) { if (ref $hash{$key}) { output_files("$path.$key",%{$hash{$key}}); } else { print "$path.$key.2.ada\n" } } } while (my($key, $value) = each %$VAR1) { output_files($key, %$value); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Filling value of nested hash
by Util (Priest) on Dec 09, 2010 at 17:13 UTC |