From: Emmanuel Oga Date: 2007-06-15T05:36:32+09:00 Subject: Re: Runtime disparity - Same program in Perl and Ruby Kaldrenon wrote: > Hi all (this is going to comp.lang.ruby and comp.lang.perl.misc), > > The other day I wrote a basic program in Perl, and the following day I > rewrote it in Ruby. I'm curious about the differences in runtime of > the two versions, though. > It would help to have a view into the input file an to know what your program should do. Im sure there has to be another way to code your problem, and im pretty sure that constructs as the following can and should be avoided: Find.find("(path)") do |file| if !(FileTest.file?(file)) || !(File.basename(file) =~ /^[\d\w\S]+_ \d{3}/) next else filecodes.each_key do |target| if(file =~ /#{target}/) puts "found " + target + " at " + file $stdout.flush fail = 0 for i in 0..filecodes[target].size-1 do if(filecodes[target][i] != "empty" && File.basename(file) == File.basename(filecodes[target] [i])) fail = 1 break end end if fail == 0 if filecodes[target][0] == "empty" filecodes[target][0] = file else filecodes[target].push(file) end end end end end end This is both difficult to read and error prone. -- Posted via http://www.ruby-forum.com/.