Leon Bogaert wrote:
> This would work:
> 
> i = 0; dir = "/home/leon/"; test = Array.new; test = 
> Dir.new(dir).entries.map! { |x| x =~ /filezilla$/ ? x : next  }; 
> test.compact
> 
> Is the .compact needed? Can't I get rid of that?

You can do something like this:

d = "./"
matching_files = Dir.open(d) do |dir|
  dir.find_all { |filename| filename == "r8test.rb"}
end
p matching_files


collect puts the return values from the block into an array. With 
find_all, if the block returns true, then the current filename is added 
to the array.
-- 
Posted via http://www.ruby-forum.com/.