![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| perl hash | pritish.sas | Shell Programming and Scripting | 3 | 07-20-2009 05:53 AM |
| perl using hash | mingming88 | Shell Programming and Scripting | 3 | 05-25-2009 06:44 AM |
| perl hash | littleboyblu | Shell Programming and Scripting | 2 | 03-19-2009 03:01 PM |
| Perl Hash | Harikrishna | Shell Programming and Scripting | 1 | 06-02-2008 11:45 PM |
| Hash in perl | Harikrishna | Shell Programming and Scripting | 1 | 06-02-2008 04:00 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
perl hash
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 ? Code:
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
|
|
||||
|
Please use code tags only for CODE.
>>> Did you mean all the data into 1 hash ? Instead of returning hash from the sub module, pass hash reference to the sub module and manipulate the hash in the sub module itself. So, there is no need to do post processing over the hash-es returned. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|