Basic HTML version of Foils prepared March 30 97

Foil 31 Associative Arrays -- Storage and Access (Chapter 5 of the Llama Book)

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


1 The order of storage of pairs in an associative array is arbitrary and nonreproducible.
  • one cannot push or pop an associative array
2 @listmime = %mime; # produces a list of form (key1,value1,key2,value2 ...)
  • This list can be manipulated like any list
  • One can also create an associate array by defining such a list where adjacent elements are paired so that in above example
3 %newmime = @listmime; # creates an associative array identical to %mime
4 One can delete specific pairs by delete command so for example:
  • %fred = (key1, "one", key2, "two"); # Quotes on key1 optional
  • delete $fred{key1}; # leaves %fred with one pair (key2,"two")

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