Accessing the values of HoH




In my most recent postings, I was dealing with first HoA and now HoH.

In my previous example code, I ended up with an output that looked something like this:

jelly -- strawberry apple grape pear
jam -- strawberry apple grape
milk -- plain strawberry chocolate

I thought I'd prefer to have it listed more like this:

jelly -- strawberry
apple
grape
pear
jam -- strawberry
apple
grape
milk -- plain
strawberry
chocolate


So in the following snippet, I tried to add a "\n" onto the value of the HoH.

for my $i ( keys %HoH ) {
%{$HoH{$i}} = join ("\n", %{$HoH{$i}}, "");
print "$i -- @{[ keys %{$HoH{$i}} ]}\n";
}

But now for an output, what I get is:
jelly -- strawberry

apple

grape

pear
jam -- strawberry

apple

grape

milk -- plain

strawberry

chocolate


This begs two questions:

1) am I correctly accessing the value of the HoH ?
2) where is the 'extra' "\n" coming from

Thanks,
Mike

--

Years of development: We finally got one to work.
01:10:01 up 14 days, 22:01, 0 users, load average: 0.51, 0.33, 0.22

Linux Registered User #241685 http://counter.li.org
.