find( { wanted => \&get_files, preprocess => \&nodirs }, "$DIR" ); sub nodirs { grep !-d, @_; } sub get_files { my @array; push @array, $File::Find::name if ( (/^.*\.($TYPES)$/i) ); }