Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Answer: How do I print a hash so that it represents actual table with column headers?

( #792514=categorized answer: print w/ replies, xml ) Need Help??

Q&A > hashes > How do I print a hash so that it represents actual table with column headers? contributed by toolic

Text::Table can be used to format the keys and values of a simple hash as a 2-column table. It automatically calculates the width of each column.
use Text::Table; my $tb = Text::Table->new(qw(Keys Values)); # column headers for my $k (keys %hash) { $tb->add($k, $hash{$k}) } print $tb;

Comment on Answer: How do I print a hash so that it represents actual table with column headers?
Download Code
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2014-07-30 02:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (229 votes), past polls