Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
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 taking refuge in the Monastery: (8)
As of 2014-10-21 03:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (95 votes), past polls