From: Clement Ow Date: 2008-05-15T10:47:35+09:00 Subject: Re: Handling of arrays >Sorry, that's what I get for not testing the code. I think (I'm a bit >dense right >now, so this might not work) that what I meant was this: Nah, it's fine, we all know it can get a lil tiring sometimes. As it is with this script im writing lol. > files = exceptions_by_path[path].inject(Dir.glob("#{path}/*")) >{|result, >ex| result.reject{|x| x =~ Regexp.new(ex)}} >end >so you get the exceptions for that path, which is an Array that should >work with >inject as I was expecting. Anw, I get what you mean, but because Im using a config file to hold all the source paths, dest paths and the file exceptions, which is keyed in by the user, I dont wanna make it too complicated to fill in the paths, so i decided to just use numbers to name the arrays in the hash. > I'm not sure if I'm understanding you correctly, but you can tweak the > regexps so that they actually match what you want. If you want > to deselect only the files that start with 2007 you can do this: > > irb(main):001:0> a = %w{20071212 20073445 risk20072341} > => ["20071212", "20073445", "risk20072341"] > irb(main):003:0> a.reject {|x| x =~ /\A2007/} > => ["risk20072341"] Oh yea, i did try this but it doesnt work, somehow *scratches head* It just shows all files to be moved, and it obviously did not carry out the exceptions. But if it's done this way, there wont be any point in keying in the various different exceptions alr, hence i got stuck. :/ -- Posted via http://www.ruby-forum.com/.