Basic HTML version of Foils prepared Sept 20 97

Foil 25 Control Structures -- if,else,unless,elsif

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


Statement blocks are sets of semicolon-separated statements enclosed in curly braces {} as in C
  • if ( TESTEXPRESSION) {
    • statement block-true;
  • } else {
    • statement block-false;
  • }
One can optionally leave off the else part, of course
  • unless ( TESTEXPRESSION ) {
    • statementblock-false;
  • } else {
    • statement block-true;
  • }
  • where again else is optional
Both if and unless constructs can use elsif constructs between if/unless and else blocks -- note spelling of elsif!



© 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