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