www.perl.com
Perl Programming
Hashes
  • Indexed by key name
    • An index in curly braces refers to a hash item
    • Each item is a scalar, so use scalar syntax $hash{$key}
    • Items are stored in random order
    • Looking up items is faster than searching through an array
    • Can directly assign a hash item

        print "A bicycle has $wheels{bike} wheels.\n";              

        $wheels{bike} = 4; # Adds training wheels 
        print "A bicycle with training wheels has $wheels{bike} wheels.\n";
      

        Output:
        A bicycle has 2 wheels.
        A bicycle with training wheels has 4 wheels.
      
Previous http://stuff.mit.edu/iap/perl/