#!/usr/bin/perl -w use strict; use Cwd; use File::Find; my $filespec = qr/\.(?:txt|pl)$/; my %dirskip = ( 'path/to/dir' => 1, 'path/to/another/dir' => 1 ); my $dir = $ARGV[0] || getcwd(); find( { wanted => \&find_function, preprocess => \&globber }, $dir ); sub find_function { return if $File::Find::name !~ /$filespec/ || (-d $File::Find::name); print $File::Find::name.$/; } sub globber{ my @files; foreach(@_){ push(@files, $_) unless $dirskip{$File::Find::name}; } return @files; }