On 3/25/11 Fri  Mar 25, 2011  1:19 PM, "Chris Stinemetz"
<chrisstinem...@gmail.com> scribbled:

> There is no possible value of 0 for what I am trying to do. So I am
> trying to do the former example:
> 
>>    if( $cell ) {

You are leaving out context here, so people not familiar with this thread
will be less likely to help you. To what "former example" are you referring?
> 
> I am trying to code the if statement correctly, but I am getting a syntax
> error:
> Below is how I am trying to code the if statement:
> 
> if ($cell >= 1 && $cell <= 900  ) { $cell = $cell ;

That is not the if statement you were advised to use (see above).

You are missing a closing brace in that line. Is that the problem? What
syntax error are you getting? You haven't included the rest of your program,
so we can't tell if the closing brace occurs later.

In the statement:

    if( $cell )

$cell is evaluated for true or false. All scalar values are valid in this
evaluation, including numerical, string, and undef, the three types of Perl
scalar values.

On the other hand, in this statement:

    if( $cell >= 1 && $cell <= 900 ) { ... }

$cell is used in a numerical context. If $cell is undefined, you may get a
warning. Are you getting a runtime warning?

Please work harder at providing the optimal amount of information in your
posts. A complete, compilable, runnable program that is as short as possible
that demonstrates the problem you are having is best.

Thanks.



-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to