D
Deepu
I am trying to print hash of hashes in table format on to the screen or
to a file. But am not able to get how this can be achieved. Can
somebody please help me on this.
Now i am printing a hash of hashes using:
while (($key, $value) = each %hash) {
print ("%-20s => %d\n", $key, $value);
}
The keys and values is actually:
"TEST1-TEST2" => '2'
"TEST2-TEST3" => '3'
"TEST1-TEST3" => '1'
"TEST2-TEST1" => '0'
I need to put the key and values in atable format like:
STATES TEST1 TEST2 TEST3
TEST1 2 1 3
TEST2 1 0 0
TEST3 4 6 3
Background:
There is actually a main table (in a file) with the static transitions
like:
STATES TEST1 TEST2 TEST3 TEST4
TEST1 Y N N Y
TEST2 N Y Y N
TEST3 N N N Y
TEST4 Y Y Y N
Y -Possible
N - Not possible
I need to count how many possible and not possible transitions have
occured with respect tp each transition.
and i will also have another file which will have some actual
transitions like:
TEST1
TEST3
TEST2
TEST1
TEST4
(This actually meant the present state is TEST1 then next state is
TEST3, then the present state is TEST3 and next state is TEST2 and so
on).
What i did was put the main table in a hash and also the actual
transitions file in a hash, compare both and print out the hash like
%hash = ( "TEST1-TEST2" => 0
"TEST2-TEST3" => 1
"TEST3-TEST4" => 2
"TEST4-TEST5" => 1
)
The numbers indicate how many times the transition has occured in
actual transition file.
Now i need to put this hash again in a table format.
STATES TEST1 TEST2 TEST3
TEST1 2 1 3
TEST2 1 0 0
TEST3 4 6 3
Thanks
Pradeep
to a file. But am not able to get how this can be achieved. Can
somebody please help me on this.
Now i am printing a hash of hashes using:
while (($key, $value) = each %hash) {
print ("%-20s => %d\n", $key, $value);
}
The keys and values is actually:
"TEST1-TEST2" => '2'
"TEST2-TEST3" => '3'
"TEST1-TEST3" => '1'
"TEST2-TEST1" => '0'
I need to put the key and values in atable format like:
STATES TEST1 TEST2 TEST3
TEST1 2 1 3
TEST2 1 0 0
TEST3 4 6 3
Background:
There is actually a main table (in a file) with the static transitions
like:
STATES TEST1 TEST2 TEST3 TEST4
TEST1 Y N N Y
TEST2 N Y Y N
TEST3 N N N Y
TEST4 Y Y Y N
Y -Possible
N - Not possible
I need to count how many possible and not possible transitions have
occured with respect tp each transition.
and i will also have another file which will have some actual
transitions like:
TEST1
TEST3
TEST2
TEST1
TEST4
(This actually meant the present state is TEST1 then next state is
TEST3, then the present state is TEST3 and next state is TEST2 and so
on).
What i did was put the main table in a hash and also the actual
transitions file in a hash, compare both and print out the hash like
%hash = ( "TEST1-TEST2" => 0
"TEST2-TEST3" => 1
"TEST3-TEST4" => 2
"TEST4-TEST5" => 1
)
The numbers indicate how many times the transition has occured in
actual transition file.
Now i need to put this hash again in a table format.
STATES TEST1 TEST2 TEST3
TEST1 2 1 3
TEST2 1 0 0
TEST3 4 6 3
Thanks
Pradeep