title: Ruby function list file recursively
body: <p>i need a recursive function to list files in a folder:</p>
  
  <pre><code>def procdir(dirname)
    data = ''
    Dir.foreach(dirname) do |dir|
      dirpath = dirname + '/' + dir
      if File.directory?(dirpath) then
        if dir != '.' &amp;&amp; dir != '..' then
          #puts "DIRECTORY: #{dirpath}" ; 
          procdir(dirpath)
        end
      else
        data += dirpath
      end
    end
    return data
  end
  </code></pre>
  
  <p>but the result: is null</p>