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

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to