use strict;
如果被注释掉,我有几行代码可以工作。但是,我不想仅仅因为一小部分就禁用整个脚本。
我需要重新编码,或者以某种方式use strict;
暂时禁用然后重新启用它。第一个选项更现实,但我不知道如何更改代码以在严格模式下工作。
my ($ctc_rec_ref) = get_expected_contacts($ctc,$fy);
my @expected_ctc_rec = @$ctc_rec_ref;
print $expected_ctc_rec[0][0]."\n";
print $expected_ctc_rec[0][1]."\n";
print $expected_ctc_rec[0][2]."\n";
sub get_expected_contacts
{
my (@ctc_rec,$i) = ((),0);
$STMT = "SELECT DISTINCT field1, field2, field3 FROM table WHERE field4 = ? AND field5 = ? AND field6 = 'E'";
$sth = $db1->prepare($STMT); $sth->execute(@_);
while(@results = $sth->fetchrow_array())
{
push @{ $ctc_rec[$i] }, $results[0];
push @{ $ctc_rec[$i] }, $results[1];
push @{ $ctc_rec[$i] }, $results[2];
$i++;
}
return (\@ctc_rec);
}
启用
use strict;
:在 ./return5.pl 第 49 行使用“strict refs”时,不能使用字符串(“0”)作为 ARRAY 引用。
(第 49 行push @{ $ctc_rec[$i] }, $results[0];
:)
禁用use strict;
:
1468778
04/01/2011
30557
如何重写此代码,使其像禁用严格模式一样工作?如果这是不可能的,可以use strict;
暂时禁用,然后在脚本中为这段短代码重新启用?