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


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