我是新的蜜蜂到perl尝试阅读简单条件的excel表。
问题是读取所有记录并检查b列是否具有“始终为空”字符串,如果是,则显示列“C”的输出
示例:For Always Null condtion
预期输出:a,b,c,f,g
答案 0 :(得分:2)
#!/usr/bin/perl
use strict;
use warnings;
use v5.14;
use Spreadsheet::ParseExcel;
use Data::Dumper;
my $ws = Spreadsheet::ParseExcel
->new()
->parse('yourfile.xls')
->worksheet(0);
my ($i, $r_max) = $ws->row_range;
my ($cell_B, $cell_C);
while ($i <= $r_max) {
$cell_B = $ws->get_cell($i,1);
$cell_C = $ws->get_cell($i,2);
say $cell_C->value
if $cell_B
and $cell_C
and $cell_B->value eq 'Always null';
} continue { $i++ }