Basic HTML version of Foils prepared Sept 20 97

Foil 18 Arrays and Lists of Scalars I

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


1 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 that are all capitalized
  • Arrays with @ as the initial character
  • Hashes (associative arrays, dictionaries) with % as initial character
2 Arrays (for example, @fred) may be initialized with a comma-separated list of scalars
  • @fred = (1, "second entry", $hw); # is an array with three entries
3 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

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