Node:Hash Literals, Next:, Previous:Hash Variables, Up:Associative Arrays (Hashes)



Literals

"Hash literals" per se do not exist. However, remember that when we evaluate a hash in the list context, we get the pairs of the hash unfolded into the list. We can exploit this to do hash literals. We simply write out the list pairs that we want placed into the hash. For example:

     use strict;
     my %table = qw/schmoe joe 7.5 1.6/;
     
would give us the same hash we had in the previous example.