Basic HTML version of Foils prepared Sept 20 97

Foil 32 Hashes -- Storage and Access

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


The order of storage of pairs in a hash is arbitrary and nonreproducible
  • one cannot push or pop an associative array
@listmime = %mime; # produces a list of form (key1,value1,key2,value2 ...)
  • This list can be manipulated like any list
  • One can also create a hash by defining such a list where adjacent elements are paired so that in above example
%newmime = @listmime; # creates a hash identical to %mime
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")



© 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