Given that you already have the listing of directories (presumably as created by a command line like
find examples -type d), I think it's pointless to talk about using File::Find (which is certainly not an improvement over the unix "find" utility).
As I understand it, the question is how to parse that listing into an appropriate html structure to render it as a nested set of unordered lists. This should be fairly simple, given that the input list is already sorted as shown in your example:
use strict;
# let's assume you read the list from stdin:
my @paths = <>;
chomp @paths;
s/:$// for @paths; # don't want the punctuation
my $prev_path = shift @paths;
my $prev_depth = ( $prev_path =~ tr{/}{/} ); # count /'s
my $indent = 1;
print "<UL>\n <LI> $prev_path: </LI>\n";
for ( @paths )
{
my $depth_now = ( tr{/}{/} );
if ( index( $_, "$prev_path/" ) == 0 )
{ # $prev_path is contained within this one, so indent
print ' ' x $indent, "<UL>\n";
$indent++;
}
elsif ( $depth_now < $prev_depth )
{ # need to back off the indentation
while ( $depth_now < $prev_depth ) {
$indent--;
print ' ' x $indent, "</UL>\n";
$prev_depth--;
}
}
print ' ' x $indent, "<LI> $_: </LI>\n"; # put ":" back in
$prev_path = $_;
$prev_depth = $depth_now;
}
while ( $indent ) {
$indent--;
print ' ' x $indent, "</UL>\n";
}
__OUTPUT__
<UL>
<LI> examples/html: </LI>
<UL>
<LI> examples/html/bars: </LI>
<LI> examples/html/headers: </LI>
<LI> examples/html/links: </LI>
<LI> examples/html/lists: </LI>
<LI> examples/html/menus: </LI>
<LI> examples/html/rgb: </LI>
<LI> examples/html/tables: </LI>
</UL>
<LI> examples/ps: </LI>
<UL>
<LI> examples/ps/marks: </LI>
</UL>
<LI> examples/splash: </LI>
<UL>
<LI> examples/splash/dropbox: </LI>
<LI> examples/splash/frame: </LI>
<LI> examples/splash/hair: </LI>
<LI> examples/splash/icon: </LI>
<LI> examples/splash/menu: </LI>
<LI> examples/splash/menubar: </LI>
</UL>
</UL>
(updated to fix one of the comments in the code; also, looking more closely at the OP, I realize that I left out some of the desired formatting in the LI elements: having an href attribute containing the full path, and using just the last component of the path as the displayed text. I'll leave that as an exercise... it should be easy enough to work out.)