From: Mmcolli00 Mom Date: 2009-07-24T01:37:01+09:00 Subject: Re: Dir.entries, output showing nils Rob Biedenharn wrote: > On Jul 23, 2009, at 11:42 AM, Mmcolli00 Mom wrote: >> AUR123443.txt >> >> #below shows nil for all files and then shows the registereduser file. >> puts RegisteredUser >> >> end >> -- >> Posted via http://www.ruby-forum.com/. > > > First, Capitalized names in Ruby are constants. You probably want a > local_variable instead. > > I'm not sure from your example and question what you really want, but > here are some options: > > # An array of filenames that start with AU > files = Dir.glob("AU*") # or Dir["AU*"] > > # Split one array into a pair of arrays (in another array) based on a > condition: > files.partition {|filename| filename[2..2] == "R"} > > (which is Enumerable#partition) > > Does that help? > My project consists of me reading the contents of a folder. The folder will have 5 files for testing. The files are named as such... AUR234_somename.txt PUR233_somename.txt.. If a file starts with AU I know that this file fits the Aero group and the third letter being 'R' tells me if it is registered. If a file fits the condition. I want to store that filename so that other programs can peform I/O tests on it. The 5 files will be replaced occasionally but with the same strict naming conventions. Each file will be meant for a different type of test. The number represent a count that will be validated later in the test as well. Good tip- I will apply lowercase letters to the filenames. I don't think the partition will help in this case though. Thanks -MC -- Posted via http://www.ruby-forum.com/.