Basic HTML version of Foils prepared March 30 97

Foil 24 Control Structures -- if,else,unless,elsif (Chapter 4 of the Llama Book)

From PERL4 Tutorial for CPS616 Computational Science for Information Age Course CPS616 -- February 1995. by Geoffrey C. Fox


Statement Blocks are sets of semi-colon separated statements enclosed in curly braces {} as in C
  • if( TESTEXPRESSION) {
    • statement block-true;
    • }
  • else {
    • statement block-false;
    • }
One can leave off the else part but if statement-true; branch is null, then it is most elegant to use unless instead
  • 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 Sat Sep 6 1997