perl - 从 xlsx 读取单元格并进行比较
问题描述
我第一次尝试使用 perl 来使用 xlsx。即使单元格包含 1'b1 或 1'b0,else 条件也会始终执行。请帮帮我。
#!/usr/bin/perl -w
use Spreadsheet::ParseXLSX;
use Spreadsheet::WriteExcel;
use Switch;
# Creates object (parser) of ParseXLSX
my $parser = Spreadsheet::ParseXLSX->new();
# call parse method thro parser object for parsing and parse it to excel variable
$excel = $parser->parse('PinMux_Spec.xlsx');
#$test_cond = "TEST.mbist_mode == 1'b0 && DIG_PINMUX.FC_pti_en == 1'b1";
$file_func = "pinmux_func.csv";
open (FH_F,">$file_func") || die "cannot open $file_func\n";
# looping thro all the sheets in .xlsx sheet
foreach $sheet (@{$excel -> {Worksheet}})
{
if(index ($sheet ->{Name},"FUNCTIONAL_MODE") !=-1 ) {
$sheetname = $sheet -> {Name};
# max row depth
$sheet -> {MaxRow} ||= $sheet -> {MinRow};
$i=0;
# Row iteration outer loop ex cell[0][0], cell[1][0]..
foreach $row ($sheet -> {MinRow} .. $sheet -> {MaxRow})
{
# max column depth
$sheet -> {MaxCol} ||= $sheet -> {MinCol};
$j=0;
# Column iteration inner loop ex. cell[0][0], cell[0][1]..
foreach $col ($sheet -> {MinCol} .. $sheet -> {MaxCol})
{
# read content of cells in each row and column
$cell = $sheet -> {Cells} [$row] [$col];
$column[$j] = $cell-> {Val};
$j++;
}
####### MAJOR CODE ########
$OEN_SIGNAL = $column[1];
print FH_F "$OEN_SIGNAL";
if($OEN_SIGNAL eq "1'b1") { print FH_F "A"; }
elsif($OEN_SIGNAL eq "1'b0") { print FH_F "B"; }
else { print FH_F "C"; }
}
}
}
实际输出
$OEN_SIGNAL-操作
1'b1-A
1'b0-B
sda_oen-C
解决方案
对不起,这是一个小错误。将 1b'1 更正为 1'b1 后,实际输出现在是正确的。我已经更正了代码和输出。我的问题解决了。我不知道是否将问题标记为已解决。所以就这样离开吧。
推荐阅读
- xamarin.forms - GoBackToRootAsync 与 Prism 中的模态导航
- javascript - D3 向堆积面积图添加工具提示
- r - R中的MLP神经网络
- flutter - PhoneAuthProvider.getCredential() 似乎使用 firebaseAuth / Flutter 被破坏了
- jquery - 如何从javascript中的变量的选择中获取值
- flutter - Flutter:如何从 Cloud Firestore 的数组数据字段中获取数据?
- sap-fiori - 自定义 OData 服务在 iOS SAP Cloud Platform 应用程序上缺少属性
- synchronization - vkCmdPipelineBarrier 澄清渲染通道同步范围
- python - Python TypeError:“int”对象在 OOP 中不可调用
- amazon-web-services - AWS - 获取与用户 ID 关联的电子邮件