Basic HTML version of Foils prepared Sept 20 97

Foil 18 Data Structures
Arrays of Arrays in Perl5 - I

From Perl5 and Advanced Perl4 Features Computational Science for Information Age Course CPS616 -- Sept 20 97. by Geoffrey C. Fox,Nancy McCracken,Tom Scavo


Read Chapter 4 of Camel Book (second edition) or manual pages on PerlLOL (List of Lists) and PerlDSC (Data Structures Cookbook) for many excellent examples
$LoL3D[$x][$y][$z] = scalar func($x,$y,$z); # scalar forces scalar context
The above is a classic (Fortran-like) 3D array except it need NOT be predefined, there are no dimensions, and Perl arrays can be ragged with $x=1 having different $y, $z ranges from $x=2, etc
  • In ragged arrays, missing elements return undef



© 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 Apr 5 1998