#!/usr/bin/perl use strict; use File::Find; # -| Configuration |------- my $basepath = '/sitedir/'; my @skipdirs = ( "private", "cgi-bin", "lib", "images", "files" ); # -| Main |---------------- find (\&findHandler, $basepath ); # -| Subs |---------------- sub findHandler { # -------------------------------------------------------- # Evaluates and processes found files; # init local vars my $filename = $File::Find::name; my $dircheck = ""; my $showfile = 1; # first, should we show this file? foreach $dircheck ( @skipdirs ) { $showfile = 1; if ( $filename =~ /$dircheck+/i ) { $showfile = 0; # skip this one; last; } } if ( $showfile ) # then do so { # first, strip leading path $filename =~ s/$basepath//i; # only after directory names. if ( -d ) # add dir to hash { print "$filename\n"; } } }