Basic HTML version of Foils prepared Sept 20 97

Foil 20 Arrays and Lists of Scalars III -- Construction

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


1 More complicated lists may be constructed:
2 ($a, @fred) = @fred; # sets $a to first element of @fred and then 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 the length of the array
5 $a = @fred; # returns $a as length of @fred
6 The function length returns the number of characters in a string
7 $a = length (@fred); # returns length in characters of first entry in @fred
8 ($a) = @fred; # 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 Sun Sep 21 1997