我有以下内容:
$sql="SELECT * FROM table WHERE name = ? ";
&checkDB( $sql , "bob" , "while" );
sub checkDB(){
my $sth=$dbh->prepare($_[0]) or warn "$DBI::errstr";
$sth->execute( $_[1] ) or warn "$DBI::errstr";
print $_[2] . "\n"; # this works
$_[2] ( my @rows= $sth -> fetchrow() ) { # this doesn't work
blah, blah, blah
}
}
我将sql语句'bob'和“while”或“unless”变量传递给子例程。 我的子程序将让我传递“while”变量(它将打印“while \ n”)但它不会让我用它来获取。我做错了什么?
我的确切错误是“script.pl附近的语法错误”}“”....如果我用实际的单词“while”替换$ _ [2],则工作正常