Perl的Data :: Dumper显示对象而不是值

Mel*_*ssa 6 perl hash ole data-dumper

 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 
Run Code Online (Sandbox Code Playgroud)

我使用模块OLE for Perl和我从工作表中获得的每个值并打印$ var然后我得到了预期的值,但是当我把所有内容放入哈希时它打印:

'first' => [
bless( do{\(my $o = 15375916)}, 'OLE::Variant'), 
bless( do{\(my $o = 15372208)}, 'OLE::Variant'),
Run Code Online (Sandbox Code Playgroud)

等等.我一定不明白哈希的事情,因为我真的很难过.

mob*_*mob 10

push @dates, $varOLE::Variant对象推送到@dates数组上,同时print $var调用隐式OLE::Variant方法将对象转换为字符串.

如果您还想@dates包含基础字符串值而不是对象本身,请说

push @dates, "$var";
Run Code Online (Sandbox Code Playgroud)

在将日期对象放入@dates数组之前将其字符串化.