Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^5: Creating a table from raw data!

by johngg (Canon)
on Nov 19, 2009 at 23:32 UTC ( [id://808299]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Creating a table from raw data!
in thread Creating a table from raw data!

I'm not sure if this the sort of data structure you are after. It isn't the same as your structure but I think it reflects the hierarchy implied by your data. I have hopefully managed to replicate the sort of data you have in the spreadsheet in my @sanData array.

use strict; use warnings; use Data::Dumper; # @sanData is equivalent to $sheet->Name() and @Column_A data # in your 'foreach my $sheet' loop. my @sanData = ( { name => q{SAN_01}, data => [ qw{ RDUB010 34:34:36:7U 87:23:89:6C RDUB090 90:39:12:6U 34:34:36:7Z 87:23:89:6N 34:38:36:7U } ], }, { name => q{SAN_02}, data => [ qw{ RDUB030 34:7U:34:36 87:89:23:6C RDUB070 90:12:39:7Z 36:34:34:6U 89:23:87:6N 34:36:38:7U } ], }, ); my $storage = {}; foreach my $rhSheet ( @sanData ) { my $name = $rhSheet->{ name }; $storage->{ $name } = {}; my $currentLUN = q{}; foreach my $dataItem ( @{ $rhSheet->{ data } } ) { if ( $dataItem =~ m{:} ) { push @{ $storage->{ $name }->{ $currentLUN } }, $dataItem; } else { $currentLUN = $dataItem; $storage->{ $name }->{ $currentLUN } = []; } } } print Data::Dumper->Dumpxs( [ $storage ], [ qw{ storage } ] );

The Data::Dumper output.

$storage = { 'SAN_01' => { 'RDUB090' => [ '90:39:12:6U', '34:34:36:7Z', '87:23:89:6N', '34:38:36:7U' ], 'RDUB010' => [ '34:34:36:7U', '87:23:89:6C' ] }, 'SAN_02' => { 'RDUB070' => [ '90:12:39:7Z', '36:34:34:6U', '89:23:87:6N', '34:36:38:7U' ], 'RDUB030' => [ '34:7U:34:36', '87:89:23:6C' ] } };

I hope this is helpful.

Cheers,

JohnGG

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-20 10:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found