in reply to Hash to HTML display
which generates:sub hash_to_html { my $x = shift; return "" unless ref($x) eq "HASH"; return "<ul>".join("", map { "<li>$_\n".hash_to_html($x->{$_}) } sor +t keys %$x )."</ul>\n"; } $our_hash = { 'Cows' => { 'Brown' => undef, 'Green' => undef, 'Strawberry' => { 'Spotted' => undef, 'Solid' => undef }, 'Orange' => undef }, 'Dogs' => { 'Purple' => { 'Spotted' => undef, 'Solid' => undef } } }; print hash_to_html($our_hash);
<ul><li>Cows <ul><li>Brown <li>Green <li>Orange <li>Strawberry <ul><li>Solid <li>Spotted </ul> </ul> <li>Dogs <ul><li>Purple <ul><li>Solid <li>Spotted </ul> </ul> </ul>
-- Randal L. Schwartz, Perl hacker
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Hash to (X)HTML display
by flocto (Pilgrim) on Jul 18, 2002 at 11:01 UTC | |
by merlyn (Sage) on Jul 18, 2002 at 14:57 UTC | |
by flocto (Pilgrim) on Jul 18, 2002 at 15:18 UTC | |
by merlyn (Sage) on Jul 18, 2002 at 17:46 UTC | |
|
Re: •Re: Hash to HTML display
by Anonymous Monk on Jul 18, 2002 at 07:30 UTC |