Basic HTML version of Foils prepared March 30 97

Foil 18 Arrays and Lists of Scalars(data) III -- Construction (Chapter 3 of Llama Book)

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


1 More complicatedly we can set constructed lists equal to each other
2 ($a, @fred) = @fred; # sets $a to first element of @fred and removes this first element from @fred
3 ($a,$b,$c) = (1,2,3); # sets $a=1, $b=2, $c=3
4 Curiously setting a scalar equal to an array returns length of array
5 $a = @fred; # returns $a as length of @fred whereas
6 The function length returns number of characters in a string
7 $a = length (@fred); # returns length in characters of first entry in @fred
8 ($a) = @fred; # defines two lists equal to each other but as LHS only has one element, this instruction sets $a to be first entry of @fred

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