use File::Find; find(\&cleanup, "test"); # Subroutine that determines whether we matched the file extensions. sub cleanup { if (/\.pdf$/) { print "$File::Find::name\n"; } }