Just a bit of elaboration on an excellent post.
The keys and values in hashes can only be scalars, you can't
directly store a array as a value. But, you can store a refrence
to a array in a hash (a reference is a scalar) which is what
btrott's code does.
When you want to make a reference to another variable use the
\ operator.
my $ref_to_array = \@an_array;
my $ref_to_hash = \%a_hash;
my $ref_to_scalar = \$a_scalar;
Or if you don't want to make a variable and then make a reference,
you can initialize them this way.
my $ref_to_array = [1,2,3,4];
my $ref_to_hash = { 'key1' => 'val1', 'key2' => 'val2' };
my $ref_to_scalar = \"some string\n";
The contents can be retrieved like:
print $ref_to_array->[0];
print $ref_to_hash->{'some_key'};
print ${$ref_to_scalar};
All this stuff is explained in the o'reily (sp?) books in
great detail. I'd suggest getting them. :)
/\/\averick