Basic HTML version of Foils prepared Sept 20 97

Foil 26 Control Structures --
What is true and false?

From Tutorial on PERL Computational Science for Information Age Course CPS616 -- Sept 20 97. by Geoffrey C. Fox,Nancy McCracken,Tom Scavo


in PERL all TESTEXPRESSIONs are converted to strings
Either the null string or string '0' (same as "0") is evaluated as FALSE
Everything else evaluates as TRUE
Results of comparison operators are what you expect
  • if ( $age < 18 ) evaluates as TRUE iff the numeric value of $age is less than 18
Note the numeric number 0 is converted to "0" and is FALSE as is numeric computation 1-1
The string "0.000" evaluates as TRUE



© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sun Sep 21 1997