0

我是 perl 新手,并且在使用电子表格 excel 解析器模块时遇到了问题。

当我在自己的行上使用 $cell->value() 时,似乎没有问题,但是当我尝试使用它将值插入数组时,它返回 undef,代码如下所示:

for my $row ($row_min .. $row_max) {
    my @line;
        for my $col ( $col_min .. $col_max) {
                my $cell = $worksheet->get_cell( $row, $col );
                $value = $cell->value;
                push @line, $value if defined($cell);
                print $cell->value;
                print Dumper $line;
                }

         }
}

这里打印 $cell->value; 返回单元格的内容但打印 Dumper $line; 返回 undef

4

1 回答 1

2

$cell->value你必须不推$value

push @line, $cell->value if defined($cell);

您应该use strict在程序的开头添加,以便在这种情况下收到错误消息。

于 2015-06-03T10:44:44.833 回答