use strict; use warnings; use Data::Dumper; use File::Find; use File::Spec::Functions qw/ splitdir /; my %files; find ( { wanted => \&process }, "P:/vb.XpVisualStyle" ); print Dumper(\%files); sub process { # $File::Find::dir = /some/path/ # $_ = foo.ext # $File::Find::name = /some/path/foo.ext return if -d; # ignore directories, we are only interested in files my $fname = $_; my @dirs = splitdir($File::Find::dir); # build hash table or HTML output here # .... # build hash table %files->{path}{path} = [@filelist] my $src = "push \@{\$files{'" . join("'}{'", @dirs) . "'}}, '$fname'"; eval "$src"; } #### $VAR1 = { 'P:' => { 'vb.XpVisualStyle' => [ 'makeres.bat', 'xp_manifest.rc', 'xp_manifest.res', 'xp_manifest.xml', 'xp_visual.exe.manifest', 'xp_visual.txt' ] } };