Ergg, just realized my copy of Programming Perl is at home. Ah well, the
old noggin is pretty sure how to do this.
Quick short answer, @{$facets{$key}}..so
foreach $foo (@{$facets{$key}}) {
print "Hello, I'm $foo. Pleased to meet ya.\n";
}
or something along those lines
Jonathan T. Gorman
Visiting Research Information Specialist
University of Illinois at Champaign-Urbana
216 Main Library - MC522
1408 West Gregory Drive
Urbana, IL 61801
Phone: (217) 244-4688
On Fri, 10 Feb 2006, Eric Lease Morgan wrote:
How do I loop through a reference to an array?
I have the following data structure:
my %facets = (
'audiences' => [('freshman', 'senior')],
'subjects' => [('music', 'history')],
'tools' => [('dictionaries', 'catalogs')]
);
I can use this code to get the keys for %facets:
foreach my $key (sort(keys(%facets))) { print $key, "\n" }
But since $key points to the reference of an array, I don't know how to
loop through the referenced array.
--
Eric Lease Morgan
Head, Digital Access and Information Architecture Department
University Libraries of Notre Dame
(574) 631-8604