J
John Maclean
I'd like to see if I can itterate through the directories
of my PATH (or $PATH for Unix-based systems) using blocks.
#!/usr/bin/ruby -w path =
ENV['PATH'].split(File:ATH_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
of my PATH (or $PATH for Unix-based systems) using blocks.
#!/usr/bin/ruby -w path =
ENV['PATH'].split(File:ATH_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