From: Stefan Schmiedl Date: 2005-02-18T18:24:54+09:00 Subject: Re: backtick vrs native ruby On Fri, 18 Feb 2005 05:09:29 +0900, Mark Probert wrote: > > Hi .. > > In one of my apps, I am doing something like > > def clean > f = `rm -f #{@datadir}/*.raw` > end > > I could, just as easily do > > def clean > Dir["#{@datadir}/*.raw"].each do |f| File.delete(f) end > end > > Besides the portability aspect (does 'rm' exist on the box?), is one to be > preferred to the other? I'd go with the second one for everything that's not a one-time hack. Depending on where the contents of @datadir originate, you might have a security problem in the first method. And you're starting an external process, which might become expensive, if done often enough. kind regards, s.