I am doing a little script that builds an array (called darray) of all
filenames in a directory tree. I am doing this by recursively calling
a method (called enter_dir) and passing the partially filled array
(called darray) down through the recursive calls.
The code works, but I am concerned about the efficiency of passing what
is potentially quite a large array around so many times. Should I be
concerned about this or not?
I also wrote the code using a global array ($darray) and this worked
too and didn’t need to array to be passed down through the recursions.
What are the pros and cons of these two approaches?
def enter_dir(this_dir, darray)
farray = 
farray << fname
file_path = this_dir.path + ‘/’ + fname
this_dir_sub = Dir.new(file_path)
if fname != ‘.’ && fname != ‘…’
darray << file_path
this_dir = Dir.new(’/home/tony/Ruby/dot_recycle’)
darray =