Sastry wrote:
> Hi

Hello,

> I have a script that gives error
> 
> "Syntax error at /u/isldev3/exp/oper.pl line 7, near ")
>   print"
> Execution of /u/isldev3/exp/oper.pl aborted due to compilation errors."
> 
> $x =3D 3;
> $y =3D 4;
> $z =3D 3;
> 
> if  (($x & $y & $z) < 20)
>   print "\n Lies below the range";
> 
> a) Is it supposed to give error?

Yes.

> b)If so why is the language construct so different compared to any
> structured language like C?

perldoc perlsyn
[snip]
       Compound Statements

       In Perl, a sequence of statements that defines a scope is called a
       block.  Sometimes a block is delimited by the file containing it (in
       the case of a required file, or the program as a whole), and sometimes
       a block is delimited by the extent of a string (in the case of an
       eval).

       But generally, a block is delimited by curly brackets, also known as
       braces.  We will call this syntactic construct a BLOCK.

       The following compound statements may be used to control flow:

           if (EXPR) BLOCK
           if (EXPR) BLOCK else BLOCK
           if (EXPR) BLOCK elsif (EXPR) BLOCK ... else BLOCK
           LABEL while (EXPR) BLOCK
           LABEL while (EXPR) BLOCK continue BLOCK
           LABEL for (EXPR; EXPR; EXPR) BLOCK
           LABEL foreach VAR (LIST) BLOCK
           LABEL foreach VAR (LIST) BLOCK continue BLOCK
           LABEL BLOCK continue BLOCK

       Note that, unlike C and Pascal, these are defined in terms of BLOCKs,
       ^^^^^^^^^^^^^^^^^^^
       not statements.  This means that the curly brackets are required--no
                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
       dangling statements allowed.  If you want to write conditionals without
       curly brackets there are several other ways to do it.


perldoc perltrap
[snip]
       C/C++ Traps

       Cerebral C and C++ programmers should take note of the following:

       ยท   Curly brackets are required on "if"'s and "while"'s.



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to