我用过:
my @ar = $stm->fetchrow_array
#to remove undefined
@ar = grep defined, @ar;
但是这不会将列名显示为参考
所以我用了
my $rec = $stm->fetchrow_arrayref
但是很难删除未定义的值,并且数组引用不是列名。
答案 0 :(得分:2)
my $rec = $stm->fetchrow_hashref;
my @to_delete = grep { !defined($rec->{$_}) } keys %$rec;
delete @{$rec}{@to_delete};