In this second part of a two-part series on hashes in Perl, you'll learn about hash functions and hashes in different contexts. This article is excerpted from chapter five of the book Beginning Perl, written by James Lee (Apress; ISBN: 159059391X).
When we discussed lists and arrays, we spent a lot of time talking about the difference between list and scalar context. Let’s look at what happens when we evaluate a hash in list context. This is demonstrated with the following program:
#!/usr/bin/perl -w # listcontext.pl
my %person = ( name => 'John Doe', age => 39, phone => '555-1212', city => 'Chicago' );