From: Robert Klemme Date: 2007-10-05T16:20:58+09:00 Subject: Re: Add files to array matching pattern 2007/10/5, Leon Bogaert : > 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 need it with your code because the map! will map some values to nil. You probably rather want #select. files = Dir.new(dir).entries.select { |x| /filezilla$/ =~ x } But you can have that much easier with files = Dir["/home/leon/*filezilla"] Kind regards robert