foreach my $row (1..$end)
{
foreach my $col (3..27 )
{
# skip empty cells
next unless defined
$worksheet->Cells($row,$col)->{'Value'};
# print out the contents of a cell
$var = $worksheet->Cells($row,$col)->{'Value'};
push @dates, $var;
print $var; #this prints the value just fine
}
}
my %hash;
$hash{'first'} = \@dates;
print Dumper \%hash; #This prints object information
I am using the module OLE for Perl and every value I get from my worksheet and print $var then I get the expected value, but when I put everything into a hash it prints:
'first' => [
bless( do{\(my $o = 15375916)}, 'OLE::Variant'),
bless( do{\(my $o = 15372208)}, 'OLE::Variant'),
And so forth. I must not understand something about hashes, because I'm really stumped here.
push @dates, $var
pushes an OLE::Variant
object onto your @dates
array, while print $var
calls the implicit OLE::Variant
method to convert the object to a string.
If you also want @dates
to just contain the underlying string values and not the objects themselves, say
push @dates, "$var";
which will stringify the date object before putting it into the @dates
array.