Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
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 scrutinizing the Monastery: (5)
As of 2014-08-29 00:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (275 votes), past polls