At 7:01 AM -0500 3/26/11, Chris Stinemetz wrote:
 >
 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 ) { ... }


I am getting a runtime error when I use the above if statement. My
goal is to only evaluate the $cell element which contain
the numerical value 1 through 900. Below is my error I am getting and
my program.

syntax error at ./DOband.pl line 22, near "{ ..."
Execution of ./DOband.pl aborted due to compilation errors.

That line is not valid Perl syntax. When I posted that example line, I assumed that you would know enough to substitute the '...' with the actual code that you wanted to execute if the value of $cell was between 1 and 900. My apologies.

I would not classify the error you have shown as a "runtime" error. It would be better described as a "compile-time" error, because it violates Perl syntax, and your program never starts executing. While with Perl, the compile phase and the execution phase are performed as one step by the user, there are nevertheless separate compile and execution phases.

If you are unsure which phase is encountering an error, you can perform just the compilation phase with the -c option to Perl:

perl -c yourprogram.pl

Perl compiles your program and checks its syntax, but does not execute it.

Please put valid Perl statements to replace { ... } and try again. And please do not blindly copy whatever people have posted. It is up to you to understand the meaning behind code examples of that sort and adapt them to your own needs.


--
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