blackadder has asked for the wisdom of the Perl Monks concerning the following question:
Bestest Monks
I am trying to creat a data structure like;
I wrote this bit of code which is not working!
In Fact; I don't slurp the data in, I populate an array direct from excel with
I am trying to creat a data structure like;
And so forth...San device : SAN3 Lun Name : LUNName3 WW Names : 60:05:08:b2:00:bb:b6:93 60:05:08:b2:00:bb:b6:92 San device : SAN4 Lun Name : LUNName4 WW Names : 66:05:08:b2:00:7d:15:13 66:05:08:b2:00:7d:15:12 66:01:43:80:00:be:79:12 66:01:43:80:00:be:79:10
I wrote this bit of code which is not working!
can someone pretty please advise how can I creat such data structures from the __DATA__ that I have?my $xls_path = "c:/path_to_xls.xlsx"; my $xls = $excel>Workbooks>Open("$xls_path"); foreach my $sheet ( in $xls>Worksheets ) { $San ={}; $San>{name} = $sheet>Name, $/; my $San_data = $xls>Worksheets("$San>{name}"); my @Colum_A = $San_data>UsedRange>{'Value'}; if ( "$Colum_A[0]" =~ /ARRAY/) { $San>{note} = 'Live SAN Box'; foreach my $array (@{$Colum_A[0]}) { foreach (@$array) { my @wwn; next if ((uc $_) eq (uc "$San>{name}")); next if not defined $_; push (@{$San>{LUNs}},$_) if ($_ !~ /:/); foreach my $LUN (@{$San>{LUNs}}) { print "\n".$LUN.": ".$_."\n" if ($_ =~ /:/); } } } } else { $San>{note} = $Colum_A[0]; } #print Dumper $San; print "\n__________\n"; } __DATA__ LUNName1 60:05:08:b2:00:bb:b6:93 60:05:08:b2:00:bb:b6:92 LUNName1 66:05:08:b2:00:7d:15:13 66:05:08:b2:00:7d:15:12 66:01:43:80:00:be:79:12 66:01:43:80:00:be:79:10 LUNName3 66:05:08:b2:00:b2:95:23 66:05:08:b2:00:b2:95:22 66:05:08:b2:00:b2:ab:a3 89:05:08:b2:00:b2:ab:a2 89:05:08:b2:00:b2:b4:c3 89:05:08:b2:00:b2:b4:c2 LUNName4 89:05:08:b2:00:b2:36:c2 89:05:08:b2:00:b9:fa:13 89:05:08:b2:00:7c:bc:03 98:05:08:b2:00:b9:fa:12 70:05:08:b2:00:7c:bc:02 70:05:08:b2:00:b2:2c:b3 70:05:08:b2:00:b2:2c:b2 70:05:08:b2:00:75:6d:73
In Fact; I don't slurp the data in, I populate an array direct from excel with
so I think this would be bettermy @Colum_A = $San_data>UsedRange>{'Value'};
Thanks@Colum_A = qw/LUNName1 60:05:08:b2:00:bb:b6:93 60:05:08:b2:00:bb:b6:92 LUNName1 66:05:08:b2:00:7d:15:13 66:05:08:b2:00:7d:15:12 66:01:43:80:00:be:79:12 66:01:43:80:00:be:79:10 LUNName3 66:05:08:b2:00:b2:95:23 66:05:08:b2:00:b2:95:22 66:05:08:b2:00:b2:ab:a3 89:05:08:b2:00:b2:ab:a2 89:05:08:b2:00:b2:b4:c3 89:05:08:b2:00:b2:b4:c2 LUNName4 89:05:08:b2:00:b2:36:c2 89:05:08:b2:00:b9:fa:13 89:05:08:b2:00:7c:bc:03 98:05:08:b2:00:b9:fa:12 70:05:08:b2:00:7c:bc:02 70:05:08:b2:00:b2:2c:b3 70:05:08:b2:00:b2:2c:b2 70:05:08:b2:00:75:6d:73/;
Blackadder


Replies are listed 'Best First'.  

Re: Creating a table from raw data!
by BioLion (Curate) on Nov 19, 2009 at 16:21 UTC  
by blackadder (Hermit) on Nov 19, 2009 at 16:29 UTC  
by BioLion (Curate) on Nov 19, 2009 at 17:59 UTC  
by blackadder (Hermit) on Nov 19, 2009 at 19:09 UTC  
by graff (Chancellor) on Nov 19, 2009 at 22:24 UTC  
by johngg (Canon) on Nov 19, 2009 at 23:32 UTC  
by BioLion (Curate) on Nov 20, 2009 at 10:18 UTC 
Back to
Seekers of Perl Wisdom