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
In reply to Re: Hash to HTML display
by vladb
in thread Hash to HTML display
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |