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


In reply to Re^5: Creating a table from raw data! by johngg
in thread Creating a table from raw data! by blackadder

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.