my @rename_files; my @modify_files; finddepth (\&get_filenames , @fixedDrives ); sub get_filenames { push(@rename_files,$File::Find::name) if( index($File::Find::name,$old_hostname) + 1 ); #index should be quicker push(@modfy_files,$File::Find::name) if ( -T $File::Find::name ); # -T is the same as -f and ! -B }