Re: Accessing the values of HoH
- From: cajun@xxxxxxxxxxxx (M. Lewis)
- Date: Fri, 29 Dec 2006 23:02:05 -0500
John W. Krahn wrote:
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";
}
This worked fine John. At first I didn't understand what was going on with the join, but after some sleep and looking at it more, I know understand it. Thanks much John!
Mike
--
The programmer's national anthem is 'AAAAAAAAHHHHHHHH'. -Weinberg, p.152
23:00:01 up 15 days, 19:51, 0 users, load average: 0.30, 0.30, 0.32
Linux Registered User #241685 http://counter.li.org
.
- References:
- Accessing the values of HoH
- From: "M. Lewis"
- Re: Accessing the values of HoH
- From: "John W. Krahn"
- Accessing the values of HoH
- Prev by Date: Re: Hashes of Hashes
- Next by Date: Negate a regular expression
- Previous by thread: Re: Accessing the values of HoH
- Next by thread: Re: Accessing the values of HoH
- Index(es):
Relevant Pages
|
|