#!/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 = ""; if ( goodDir( $filename ) ) # then do so { # first, strip leading path $filename =~ s/$basepath//i; # only after directory names. if ( -d ) # add dir to hash { print "$filename\n"; } } } sub goodDir { # -------------------------------------------------------- # Evaluates a file's dir to see if we want to print it. my $filename = $_; # file we're testing my $dircheck = ""; # loop counter my $showfile = 1; # assume success # first, should we show this file? foreach $dircheck ( @skipdirs ) { $showfile = 1; if ( $filename =~ /$dircheck+/i ) { $showfile = 0; # skip this one; last; # skip rest of loop; } } return $showfile; }