下面是一段Perl代码.我想循环使用不同的正则表达式($myo)和不同的运算符($op)的几个查询,并将结果保存到数组数组而不是一个大@result数组.
即,结果为数组MYO[0-9]*$将是各运营商的阵列$results[0][0],$results[0][1]和... ... MYO[0-9]*R$,$results[1][0],$results[1][1].
有任何想法吗?
my @tech_ops = ("AR","DB","GM","LW","MM","SA");
my @results;
for my $myo (qw(MYO[0-9]*$ MYO[0-9]*R$ MYO[0-9]*T$ MYO[0-9]*U$)) {
foreach $op (@tech_ops)
{
$sth->execute($myo, $date_stop, $date_start,$op)
or die "Couldn't execute query for $myo: " . $sth->errstr;
push @results, $sth->fetchrow_array;
}
}
Run Code Online (Sandbox Code Playgroud)
使用该fetchall_arrayref方法而不是fetchrow_array方法.
所以只需替换这一行:
push @results, $sth->fetchrow_array;
Run Code Online (Sandbox Code Playgroud)
有了这条线:
push @results, $sth->fetchall_arrayref;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4981 次 |
| 最近记录: |