【发布时间】:2020-08-04 14:18:21
【问题描述】:
这段代码:
#!/usr/bin/perl -w
sub marine{
print "somestuff\n";
exit 1;
}
$bool=1;
if($bool)
marine();
给出这个错误:
Bareword found where operator expected at ./a line 10, near ")
marine"
(Missing operator before marine?)
syntax error at ./a line 10, near ")
marine"
Execution of ./a aborted due to compilation errors.
但是,当 if 正文中有 {} 时,它可以工作。 Perl 是否需要它们?
【问题讨论】:
标签: perl if-statement curly-braces