in reply to Hash to HTML display
Which yields this output:use CGI; my $cgi = new CGI; my $our_hash = { 'Cows' => { 'Brown' => undef, 'Green' => undef, 'Strawberry' => { 'Spotted' => undef, 'Solid' => undef }, 'Orange' => undef }, 'Dogs' => { 'Purple' => { 'Spotted' => undef, 'Solid' => undef } } }; use Data::Dumper; print $cgi->header(); print "<html><title>Page Title</title><body>"; #print Dumper($our_hash); sub traverse_hash { my $ahash = $_[0]; my $r; print "<ul>\n"; for (keys %$ahash) { $r = $ahash->{$_}; print "<li> $_\n"; traverse_hash($r) if (ref $r eq 'HASH'); } print "</ul>"; } $DB::single = 1; print traverse_hash($our_hash); $DB::single = 1; print "</body></html>";
Update: darn! merlyn beat me to it ;-)...Content-Type: text/html; charset=ISO-8859-1 <html><title>Page Title</title><body><ul> <li> Dogs <ul> <li> Purple <ul> <li> Spotted <li> Solid </ul></ul><li> Cows <ul> <li> Green <li> Brown <li> Strawberry <ul> <li> Spotted <li> Solid </ul><li> Orange </ul></ul>1</body></html>
# Under Construction
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(jeffa) 2Re: Hash to HTML display
by jeffa (Bishop) on Jul 19, 2002 at 04:01 UTC |