Spent ages debugging the above to no avail,..still didn't work!
I started again
Now; I have this data in colum A in excel
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
And i want to create a data structure like this
San : SAN_01
Lun: RDUB010
WWn1: 34:34:36:7U
WWn2: 34:34:36:7U
Lun: RDUB090
WWn1:90:39:12:6U
WWn2:34:34:36:7Z
WWn3:87:23:89:6N
WWn4:34:38:36:7U
San: SAN_02
.
.
.
and so forth
So I put this PERL script together to do the job;
#! c:/perl/bin/perl.exe
#
#
use strict;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel';
use Data::Dumper qw/Dumper/;
use vars qw/$Storage/;
my $data;
$Win32::OLE::Warn =2;
my $excel = Win32::OLE->GetActiveObject('Excel.Application') || Win32:
+:OLE->new('Excel.Application');
my $xls_path = "c:\\test.xlsx";
my $xls = $excel->Workbooks->Open("$xls_path");
foreach my $sheet ( in $xls->Worksheets )
{
$Storage ={};
$Storage->{SAN} = $sheet->Name, $/;
print $Storage->{SAN}."\n";
my $San_data = $xls->Worksheets("$Storage->{SAN}");
my @Colum_A = $San_data->UsedRange->{'Value'};
foreach my $array (@Colum_A)
{
foreach my $element (@$array)
{
foreach my $info (@$element)
{
if ($info !~ /:/)
{
next if not defined $info;
push (@{$Storage->{LUNs}}, "$info");
}
if ($info =~ /:/)
{
push (@{$Storage->{LUNs}}->{WWN}}, "$info");
}
}
}
print "\n_______________\n";
}
print Dumper $Storage;
}
When I ran the script I get this output, which is wrong
SAN_01
______________
$VAR1 = {
'ARRAY(0x1b68610)' => {
'WWN' => [
'34:34:36:7U',
'87:23:89:6C',
'90:39:12:6U',
'34:34:36:7Z',
'87:23:89:6N',
'34:38:36:7U',
]
},
'LUNs' => [
'RDUB010',
'RDUB090'
],
'SAN' => 'SAN_01'
};
Could someone for the love of God or Perl tell me where am I going wrong and what can I do to get it right? THANKS A BUNCH