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


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

in Table To:


© 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