use File::Find; find (\&wanted, $DIRECTORY); sub wanted { # this subroutine gets called once for each file # Inside this subroutine, $_ is set to the # name of the current file and the current # directory is the directory where that file # is stored }