mardi 4 août 2020

Are braces required in if condition in perl?

this code:

#!/usr/bin/perl -w

sub marine{
    print "somestuff\n";
    exit 1;
}
$bool=1;

if($bool)
    marine();

gives error:

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.

However it works, when there are {} in the if body. So are they required in perl?

Aucun commentaire:

Enregistrer un commentaire