Basic HTML version of Foils prepared March 30 97

Foil 16 Arrays and Lists of Scalars(data) I (Chapter 3 of Llama Book)

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


PERL has four types of variables distinguished by their initial character
  • Scalars with $ as initial character
  • File Handles with Nothing special as their initial characters and conventionally represented by names which are all capitalized
  • Simple arrays with @ as the initial character
  • Associative arrays or dictionaries with % as initial character
Arrays , represented by @fred are defined by comma-separated list of scalars
  • @fred = (1, "second entry", $hw); # is an array with three entries
Array entries can include scalar variables and more generally expressions which are evaluated when the array entry is USED not when it is DEFINED -- this is a difference from C but is for instance similar to functions in a spreadsheet
  • @fred= (1, $hw . " more", $a+$b); # is an example of this



© 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