Hashes (Associative Arrays)

This section deals with a special kind of array in Perl called a hash. Hashes, sometime called associative arrays, contain paired data. Each pair in the hash contains a key that acts as an index to a value that is associated with it. Hashes represent a simple yet powerful idea whose use makes programs more efficient and maintainable.

Hash Functionality

In this section we explore the functionality built into Perl for manipulating hashes. We start with an example hash that maps rock groups to their lead singers. See the folder Groups.

 % type groups.pl # # groups.pl # %groups = ( U2 => Bono, Stones => "Mick Jagger", Aerosmith => "Steve Tyler", Heartbreakers => "Tom Petty", Journey => "Steve Perry", Queen => "Freddie ...

Get Programming PERL in the .NET Environment now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.