Basic HTML version of Foils prepared March 30 97

Foil 59 Additional Control Flow Constructs IV -- && || and ?
(Chapter 9 of the Llama Book)

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


1 thatcommand if thiscondition; # is equivalent to
2 thiscondition && thatcommand;
3 because PERL will not continue with && (logical and) if it finds a false condition. So if thiscondition is false, thatcommand is not executed
4 Similarily:
5 thatcommand unless thiscondition; # is equivalent to
6 thiscondition || thatcommand;
7 Note can use and instead of && and or instead of ||
  • not (instead of !) and xor (instead of ^) also allowed
8 We can use a C like expression
9 expression ? Truecalc : Falsecalc; # which is equivalent to
10 if (expression) { Truecalc; } else { falsecalc; }

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 Sat Sep 6 1997