From: 7stud -- Date: 2007-10-02T23:45:22+09:00 Subject: Re: finding files with regular expressions David A. Black wrote: > > A little more concise: > > results = Dir.entries("./programs_ruby").grep(/mod/) > > Or you could do: > > results = Dir["*mod*"] > > to automatically exclude hidden files, if that's desired. > Thanks. I have some questions though. I notice that a lot of people that post to the this forum don't employ iterators for reading input as they go. Instead, they tend to slam everything into memory first, and then they work on iterating over the data--often with no care at all if they happen to create a copy or two of the data along the way. I always try to ask myself, "What if the input is 2-3GB?" I realize that's probably not going to be the case with filenames, but who knows? There are multi Terabyte hard drives now. As a result, I always try to iterate over input as I go rather than read it into memory in one chunk. Is there something I am missing about ruby in that regard? I assume that ruby iterators buffer file i/o. Is that not the case? Is ruby so inefficient that you need to read everything into memory in the biggest chunks possible to get reasonable performance while iterating over data. Also, on a side note, it seems like it's standing operating procedure to shuttle as much code as you can into shell commands. Is that because people want to avoid using the ruby interpreter? -- Posted via http://www.ruby-forum.com/.