Twitter Updates

Saturday, 28 March 2009

Ruby list directory contents

Ruby listing directory contents:
Dir.entries returns the array,
Dir.foreach itterates.
#!/usr/bin/env ruby 

mycontents = Dir.entries("/")
mycontents.each { |x|
puts x
}

Dir.foreach("/") { |x|
puts x
}

No comments: