Re: Accessing the values of HoH
- From: krahnj@xxxxxxxxx ("John W. Krahn")
- Date: Fri, 29 Dec 2006 00:20:42 -0800
M. Lewis wrote:
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";
}
Try it like this:
for my $i ( keys %HoH ) {
my $key = "$i -- ";
print $key, join( "\n" . ' ' x length $key, keys %{ $HoH{ $i } } ), "\n";
}
John
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall
.
- Follow-Ups:
- Re: Accessing the values of HoH
- From: M. Lewis
- Re: Accessing the values of HoH
- References:
- Accessing the values of HoH
- From: "M. Lewis"
- Accessing the values of HoH
- Prev by Date: Re: Fwd: click_button gives error on a existing button
- Next by Date: Determine script full path.
- Previous by thread: Accessing the values of HoH
- Next by thread: Re: Accessing the values of HoH
- Index(es):