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

Re: Help with Dumping data. Manipulate hashes output.

by Cristoforo (Deacon)
on Jun 05, 2012 at 18:32 UTC ( #974519=note: print w/ replies, xml ) Need Help??


in reply to Help with Dumping data. Manipulate hashes output.

Here is a small program to illustrate building a table, (using Text::Table).

#!/usr/bin/perl use strict; use warnings; use Text::Table; my $data = [ { 'model' => 'Cisco 7911', 'name' => 'SEP00229004C80A', 'product' => 'Cisco 7911' }, { 'model' => 'Cisco 7911', 'name' => 'SEP00229004C851', 'product' => 'Cisco 7911' }, { 'model' => 'Cisco 7911', 'name' => 'SEP00229004CC92', 'product' => 'Cisco 7911' }, ]; my @headers = qw/ Model Name Product /; my $tb = Text::Table->new( map {title => $_}, @headers ); for my $href (@$data) { $tb->load( [ @$href{ map lc, @headers } ] ); } print $tb;

***prints

Model Name Product Cisco 7911 SEP00229004C80A Cisco 7911 Cisco 7911 SEP00229004C851 Cisco 7911 Cisco 7911 SEP00229004CC92 Cisco 7911

Chris


Comment on Re: Help with Dumping data. Manipulate hashes output.
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://974519]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2015-07-05 09:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (61 votes), past polls