### begin_: init perl use strict; use warnings; use File::Basename; use File::Find; ### begin_: process all files in the dir tree my $oDataTable = dirTreeToDataTable("c:/temp"); for my $oDataRec (@{$oDataTable}){ next unless $oDataRec->{extension} eq '.html'; ProcessTheFile($oDataRec->{path}); } #### ### begin_: subroutines ### ### main: ### - name : ProcessTheFile ### desc : fill_in_the_blank ### sub ProcessTheFile { my $sFilePath = shift || die "missing required argument path."; ### munge your file however you want ### $sFilePath print "we finished mucking with $sFilePath\n"; }###end_sub ### begin: function docs ### ### main: ### - name : dirTreeToDataTable($startdir) ### desc : | ### Recurse all folders and files under start ### directory and return a listing. ### The return listing is a data table. ### Perl Array of Hashes (AoH). ### usage : | ### my $oDataTable = dirTreeToDataTable($startdir); ### sub dirTreeToDataTable{ my ($startdir) = @_; my @outArray = (); my $recNum = 0; if($startdir){ $startdir =~ s!(\\)!/!igm; # normalize to unix-style pathsteps }else{ return; } &find( sub { my @suffixlist = qw( \..* ); my ($basename,$path,$extension) = File::Basename::fileparse($File::Find::name,@suffixlist); ### INIT my $sTemp = $File::Find::name; my $pathsteps = ''; my $outrec = {}; ### dirTreeToDataTable_datarec_fields_ $outrec->{name} = "$basename$extension"; $outrec->{basename} = "$basename"; $outrec->{extension} = "$extension"; $outrec->{path} = "$File::Find::name"; $outrec->{dir} = "$path"; $outrec->{type} = (-f "$outrec->{path}")? "file" : "dir"; $outrec->{size} = -s "$File::Find::name"; my @pathsteps = (split m!/!,$outrec->{path}); $outrec->{depth} = scalar @pathsteps; $outrec->{startdir} = $startdir; push @outArray, $outrec; } ,$startdir ); return \@outArray; }###end_sub ### begin_: end perl 1; __END__