Re: Printing hash of hashes in table format



Deepu wrote:
Hi All,

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


Perhaps you could explain the relationship
between the data in your hash above and
the data in your table above. I don't see any.

I could guess that you mean this:

STATES TEST1 TEST2 TEST3

TEST1 - 2 1

TEST2 0 - 3

TEST3 - - -

but I'm not sure.

--
Brad

.



Relevant Pages

  • Tie::IxHash::Easy with "eval()"
    ... Since the hash can contain other hashes, ... I'm reading the entire hash from a file. ... The format of the file is exactly ...
    (comp.lang.perl.misc)
  • Printing hash in table format
    ... Now i am printing a hash of hashes using: ... I need to put the key and values in atable format like: ... STATES TEST1 TEST2 TEST3 ... There is actually a main table with the static transitions ...
    (comp.lang.perl.misc)
  • Re: [RFC/PATCH] Documentation of kernel messages
    ... it is one option to use the format ... string of the message as message ID. ... message IDs like hashes is, that format strings might be even less ... of course you hash on the string before you do the format stuff.... ...
    (Linux-Kernel)
  • Re: People ~Fing with Life
    ... That is what the charge was. ... hash values and the like'. ... this data area had no corresponding entry in the allocation tables. ... Hashes are used for the purposes of error correction ...
    (uk.legal)
  • Re: Passwords: to crypt or to hash?
    ... read recently that hashes are stored rather than crypted versions. ... Very few systems have ever stored crypted passwords. ... the hash function took over a second to compute. ...
    (comp.security.misc)