in reply to Hash to HTML display
Not really pretty or robust, but it works with a simple hash like your sample ... you'd need to flesh it out a little if you wanted it to be able to handle quotes, etc. Like I said, Merlyn's solution is better, but I couldn't resist giving this a try...#!c:/perl/bin/perl -w use strict; use Data::Dumper; my $our_hash = { 'Cows' => { 'Brown' => undef, 'Green' => undef, 'Strawberry' => { 'Spotted' => undef, 'Solid' => undef }, 'Orange' => undef }, 'Dogs' => { 'Purple' => { 'Spotted' => undef, 'Solid' => undef } } }; $Data::Dumper::Quotekeys = 0; for (Dumper $our_hash){ s/\$VAR1 = //; s/{/<UL>/g; s/}/<\/UL>/g; s/(undef)?[,;]?\n/\n/g; s/\n *([^\n]*)=>/\n<LI>$1<\/LI>/g; print; }
Update: Added closing </LI> tag per flocto's encouragement.
-- grummerX
|
|---|