Could anybody help me to figure out what is wrong with this script. I am
new to ruby and this script is supposed to make a playlist, which it
does do, but when I try to use the playlist it is empty. Thanks.

def shuffle(arr)
  shuf = []

  while arr.length > 0
    rand_sel = rand(arr.length)

    curr_sel = 0
    new_arr = []

    arr.each do |x|
      if curr_sel == rand_sel
        shuf.push(x)
      else
        new_arr.push(x)
      end

      curr_sel = curr_sel + 1
    end

    arr = new_arr
  end

  shuf
end

songs = shuffle(Dir[' **/*.mp3'])

File.open "dat playlist.m3u", "w" do |x|
  songs.each do |mp3|
    x.write mp3 + "\n"
  end
end

puts "Das it mane. Das it"

-- 
Posted via http://www.ruby-forum.com/.