#!/usr/bin/ruby -w path =
ENV['PATH'].split(File::PATH_SEPARATOR)
path.each{|zz| Dir.new zz}
There's an example of using nested for loops in
file:///usr/share/doc/ruby-1.8.4/sample/dir.rb
...
# directory access
# list all files but .*/*~/*.o
dirp = Dir.open(".")
for f in dirp
case f
when /^\./, /~$/, /\.o/
# do not print
else
print f, "\n"
end
end
dirp.close
--
John Maclean
MSc (DIC)
07739 171 531
files = []
filter = /^\./, /~$/, /\.o/ # btw, this regex is invalid.
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
files.concat Dir.open(path).select { |d| !d.match(filter) }
end
If thats totally not what you're trying to do, then maybe you could
clarify? Also, the regex you list isnt valid, the forward slashes need
to be escaped, but even then, there wont be any forward slashes in your
file names.
Scott