in reply to Syntax error - beginner question

Perl doesn't support expressions like   if (9 < $X < 100) Instead, you'll need to phrase it like   if (9 < $X && $X < 100) Or, to be clearer on your intent   if ( $X >=10 && $X <=99 ) though this may be a matter of style.

Replies are listed 'Best First'.
Re: Re: Syntax error - beginner question
by exussum0 (Vicar) on Jan 11, 2004 at 17:12 UTC
    Added note on the style thing.. becareful with &&, it has a low high* enough precedence that it gets interpreted early. From perlop...
    As more readable alternatives to `&&' and `||' when used for control flow, Perl provides `and' and `or' operators (see below). The short- circuit behavior is identical. The precedence of "and" and "or" is much lower, however, so that you can safely use them after a list oper- ator without the need for parentheses:
    Update:* Tnx davido for the correction.

    Play that funky music white boy..
      The precedence rules are usually sensible. It's fairly common to combine comparisons with logical operators; hence comparisons have higher precedence.