Hi,
I have a hash in hash file in perl which looks some thing like this:
I want to display the values present in the inner hash i.e 'Description' and 'Run Instructions'.
I start off with somethng like this:
The problem is that while I run the loop to display the items present in 'Description' I dont get the keys in the order they are present in the hash file i.e if for the hash 'abc' ,I want 'Purpose' first followed by 'Background'... But while sorting the order gets shuffled...and I end up getting the information but the keys are shuffled..I also dont want to sort it as that does not fulfill my requirement.
I want the keys present in the inner hash exactly in the same order as it is present in the file..
Please reply as soon as possible...
I have a hash in hash file in perl which looks some thing like this:
Code:
$FIELDS = {
'abc' => {
'Description' => {
'Purpose' => 'some data is present',
'Background' => 'something',
}
'Run Instructions' => {
'Data' => 'something',
'DEFAULT.INITIAL_WIPE' => 'somethng',
'DEFAULT.SC_ON' => 'somethng',
}
'File' => '1',
'Category => 'somethng',
},
'xyz' => {
'Description' => {
'Purpose' => 'some data is present',
'Background' => 'something',
}
'Run Instructions' => {
'Data' => 'something',
'DEFAULT.INITIAL_WIPE' => 'somethng',
'DEFAULT.SC_ON' => 'somethng',
}
'File' => '2',
'Category => 'somethng',
},
............so on and so forth
};
I start off with somethng like this:
Code:
%mydata = $FIELDS;
foreach my $key (sort {$myData{$a}{Category} cmp $myData{$b}{Category} or
$myData{$a}{File} cmp $myData{$b}{File}} keys %myData) {
.....................
..................
if ($myData{$key}{'Description'}){
print "<br><b>Description:</b><br>";
my $counterdesc = $myData{$key}{'Description'};
%desc = %$counterdesc;
while (($keydatadesc,$valuedatadesc) = each(%desc)) {
if ($keydatadesc =~ /^Data$/) {
print $valuedatadesc."<br>";
}
}
foreach my $keydesc (keys %desc) {
if ($keydesc !~ /^Data$/) {
print "<font
color=blue><b>$keydesc:</b></font><br>";
if ($desc{$keydesc} !~ /^$/) {
print $desc{$keydesc}."<br>";
}
else {
print $desc{$keydesc}."<br><br>";
}
}
}
}
......Somethng for Run Instruction also
.....
}
I want the keys present in the inner hash exactly in the same order as it is present in the file..
Please reply as soon as possible...
Comment