Basic HTML version of Foils prepared Sept 20 97

Foil 62 Additional Control Flow Constructs IV

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


thatcommand if thiscondition; # is equivalent to
thiscondition && thatcommand;
PERL will not continue with && (logical and) if it finds a false condition. So if thiscondition is false, thatcommand is not executed
Similarly:
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 if-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 Sun Sep 21 1997