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


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



© 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