Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
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 chilling in the Monastery: (14)
As of 2016-02-12 18:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?





    Results (411 votes), past polls