Hi i am reading one file and creating Hash from the contents of it my issue is there are 3 different files in 3 different locations having same structure so for parsing these files i have one subroutine which returns hash after reading all the 3 files i need to create consolidated hash from three how to do it ?
i managed to do it just wondering are there any better ways to do the same ?
output of data::dumper
direct =>{
1 => {
'one' => '1',
'two' => '2',
'thr' => '3',
}
} ;
indirect =>{
1 => {
'one' => '1',
'two' => '2',
'thr' => '3',
}
} ;
i want to copy this in new hash at the end
# $ret is original hash
# $n is new hash
foreach my $k ( keys %$ret )
{
foreach my $m ( keys %{$ret->{$k}} )
{
foreach my $n ( keys %{$ret->{$k}->{$m}} )
{
$n->{$k}->{$m}->{$n} = $ret->{$k}->{$m}{$n}
}
}
}
above code is working just wondering is this the right way ?? or there are any better ways to do this . i dont want to use module for this