From: Rudolf Polzer Date: 2002-12-29T08:35:04+09:00 Subject: Re: block from string Scripsit ille Robert : > > "Rudolf Polzer" schrieb im Newsbeitrag > news:slrnb0rvel.5qc.AntiATField_adsgohere@katsuragi.durchnull.ath.cx... > > Scripsit ille Robert : > > > "Rudolf Polzer" schrieb: > > [...] > > > > ((ARGV.length() == 0) ? Dir["..?* .[^.]* *"] : ARGV).each() do |_| > > [...] > > > > And - note the ugly glob pattern. Is there something cleaner for "take > > > > everything from the current directory except . and .."? > > > > > > how about using "next": > > > > > > ( ARGV.empty? ? Dir : ARGV ).each() do |_| > > > next if _ == "." || _ == ".." > > > > Right, since it isn't useful or possible at all to rename '.' and '..'. > > > > > _2 = _.instance_eval( expr ) > > > puts "%s => %s" % [_, _2] > > > File.rename(_, _2) unless File.exists?(_2) > > > end > > just out of curiosity: why do you use the variable names "_" and "_2" > instead of "file" or something else which is more obvious? is there any > hidden optimization which i overlooked? No, in the old version it was less characters to type. Any one-character variable name would have been OK. Note it was originally called rename.rb _.downcase * Now it can be changed. -- [mpg123d] Just playing: .../08 ame no hi no sugoshikata - new recording.mp3 The math could be slightly incorrect, but it sounds right. RFC 2795