Basic HTML version of Foils prepared March 30 97

Foil 10 Operators for Numbers and Strings III -- Binary Assignment (Chapter 2 of Llama Book)

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


1 Assignments are $Next_Course = "CPS615";
2 $Funding = $Funding + $Contract;
3 The latter can be written as in C as
4 $Funding += $Contract;
5 Similarly can write for strings:
6 $Name= "Geoffrey"; $Name .= " Fox" # Sets $Name to "Geoffrey Fox"
7 Example: $A = 6; $B = ($A +=2); # sets $A = $B = 8
8 AutoIncrement and Autodecrememt: as in C
  • $a = $a + 1; $a +=1; and ++$a; # are the same and increment $a by 1
9 ++ and -- are both allowed and can be used BEFORE(prefix) or AFTER(suffix) variable(operand). Both forms change operand in same way but in suffix form result if used in expression is value BEFORE variable incremented.
  • $a=3; $b = (++$a) # sets $a and $b to 4
  • $a=3; $b = ($a++) # sets $a to 4 and $b to 3

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