use File::Find; find(\&printer, "/path/to/dir"); sub printer { print "I have found $File::Find::name\n" if /\.pl$/; }