Hi,
I have a hash in hash file in perl which looks some thing like this: - $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 want to display the values present in the inner hash i.e 'Description' and 'Run Instructions'.
I start off with somethng like this: - %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
-
.....
-
}
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...
5 2539
There is no urgent help here so in the future don't ask for it.
If you want to maintain order, use an array to store the hash keys you want to display in a certain order.
Hi Kevin,
I tried doin it in the array...But stil the problem did not resolve..I figured out tht there is some problem while I dereference the hash 'Description'.M working on that..
Thanks..
When you want help with your code, post it.
Hey kevin,
Thanks for the reply.Next time I shall post the code...
I got the solution for the problem...
Thnks again for the help!!!!
Hey kevin,
Thanks for the reply.Next time I shall post the code...
I got the solution for the problem...
Thnks again for the help!!!!
Well, considering I was no help to you that I can see, you're very welcome.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: |
last post by:
The data file is a simple Unicode file with lines of text. BCP
apparently doesn't guarantee this ordering, and neither does the
import tool. I want to be able to load the data either sequentially...
|
by: tilak.negi |
last post by:
We have one single hash (#) table, in which we insert data processing
priority wise (after calculating priority).
for. e.g.
Company Product Priority Prod. Qty Prod_Plan_Date
C1...
|
by: Sebastian Dau |
last post by:
Hello,
I'm writing a security related application in .NET 1.1
and I wonder how I compute hashes from very large files (up to 1 GB).
Does anybody know a good pattern of how to create a stream...
|
by: spohle |
last post by:
hi i have a normal dictionary with key and value pairs. now i wanna
sort by the keys BUT in a specific order i determine in a list !? any
ideas
dic = {'key1':'value1', 'key2':'value2',...
|
by: kdotsky |
last post by:
Hello,
I am using some very large dictionaries with keys that are long strings
(urls). For a large dictionary these keys start to take up a
significant amount of memory. I do not need access to...
|
by: blackice |
last post by:
Hello All,
i have a Perl Script that deleting Zones from named.conf file and here is the script
#!/usr/bin/perl -w
use strict;
print "please enter the domain name: ";
chomp (my...
|
by: Emily Wang |
last post by:
I have a code package, whick can be compiled, run correctly on linux,
but I have to transplant it to windows vc 2005
Some problems arrise, it is not compatible...
I need a compatible hash file...
|
by: Protim |
last post by:
How can I read a hash file using C#
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |