Thanks to Chris Nador. I've found another way. Basically, this algorithm is based on the level notion. i.e. each node in the tree is assigned a level. Here's a rough description: Traverse the tree, if the current file's level is same as previous file's level, then do nothing special; if the current is greater than previous by n, then print n number of "<ul>"; if current is less than previous, then print n "</ul>" as before. Each time the above "which" is evaluated, print a "<li>currentFileName" at the end. I find it extremely difficult to implement the above inside a subroutine passed to File::Find::find, because the way File::Find::find was written. What I did was to use "File::Find::find" to read the whole file tree into an array, and process array outside the "find". Here's the script for those interested. #!/usr/local/bin/perl5 -w use strict; use File::Find; use File::Basename; my $inputFilePath=q{user347:T2:perl_files_dir:}; my @fileListArray; find(sub {push(@fileListArray,qq($File::Find::name\n));},$inputFilePath); # cLevel stands for currentLevel. pLevel stands for previousLevel. my $cLevel=0; my $pLevel=0; my $currentFileFullName; print qq(<ul>\n); foreach $currentFileFullName (@fileListArray) { $cLevel = substr($currentFileFullName,length($inputFilePath)) =~ tr(:)(); if ($cLevel == $pLevel) {;} elsif ($cLevel > $pLevel) {foreach $_ ($pLevel+1 .. $cLevel) {print qq(\t)x$_ . qq(<ul>\n)};} else {foreach $_ (reverse($cLevel+1 .. $pLevel)) {print qq(\t)x$_ . qq(</ul>\n)};}; print qq(\t) x $cLevel . qq(<li>) . basename($currentFileFullName) . qq(\n); $pLevel=$cLevel; }; print qq(</ul>\n); __END__ This task should be easily done by a recursive algorithm, but cannot be done with File::Find::find because the way it is written. Specifically, because it starts with the directory instead of it's content. File::Find::find is flawed in many other ways as well. I've received a few solutions, all seems to be very complex. Quite an unwholesome situation. Btw, who wrote File::Find? Xah, xah@best.com http://www.best.com/~xah/Wallpaper_dir/c0_WallPaper.html "Unix + C + Perl = apocalypse now" ***** Want to unsubscribe from this list? ***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch