in reply to Directory Tree..Thanks

Here's an example that does no recusion of its own - it leaves that to File::Find. Instead, it puts everything into an array, and iterates through the array, detecting when a change of dir happens, by looking at the depth of the individual item. Probably as clear as mud? :)

It doesn't use File::Basename either, but does depend on you knowing the folder delimiter for your platform ('/' for me)

#!/usr/local/bin/perl -w use strict; use File::Find; sub logGeneral { print @_, "\n";} my $delim = '/'; my $padding = ' '; my $depth = 0; my $ltype = 'OL'; my $dir = $ARGV[0]; $dir ||= '.'; # sorted array of file and folder names our @files; sub proc { push @files, [ split $delim, $File::Find::name ]; } find(\&proc, $dir); # format it as a list! my $lastdepth = 0; for my $file ( @files ) { if ( scalar @$file > $lastdepth ) { # first entry in a sub-folder logGeneral $padding x $depth, "<$ltype>"; $depth++; logGeneral $padding x $depth, "<LI>$file->[$#$file]"; } else { if ( scalar @$file < $lastdepth ) { # have left a sub-folder # may have jumped back several levels for my $i ( 1 .. $lastdepth - scalar @$file ) { $depth--; logGeneral $padding x $depth, "</$ltype>"; } } logGeneral $padding x $depth, "<LI>$file->[$#$file]"; } $lastdepth = scalar @$file; } # finish off from the last entry for my $i ( 1 .. $lastdepth ) { $depth--; logGeneral $padding x $depth, "</$ltype>"; }

Regards,

Jeff