Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: Help with Dumping data. Manipulate hashes output.

by Cristoforo (Curate)
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;


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


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://974519]
[choroba]: I wouldn't want to maintain it in the current form
[erix]: ok, but mainainability comes after it has been made to work :)
[erix]: maybe I should have cobbled together a more simple example
[erix]: the main question is whether repeating groups get captured. I thought they did but it looks they do not.
[erix]: or they probably get overwritten when the repeating is done

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2018-01-19 08:36 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (216 votes). Check out past polls.