2007/8/27, Rebhan, Gilbert <Gilbert.Rebhan / huk-coburg.de>:
>
> Hi, Robert
>
> -----Original Message-----
> From: Robert Klemme [mailto:shortcutter / googlemail.com]
> Sent: Friday, August 24, 2007 10:30 PM
> To: ruby-talk ML
> Subject: Re: Dir, recursive filescan
>
> /*
> files = Dir["E:/test/foobar/scripts/**/*.xml"]
> matches = files.inject(0) {|sum,f| sum + File.read(f).scan('<if>').size}
> printf "%10d matches\n%10d files\n", matches, files.size
>
> If you have a lot of files it may pay off to use Find.find instead of
> Dir[].
> */
>
> thanks, works like a charm :-)
> Never used  the inject method until now, i'm still on newbie level.

Took me a while, too. But if you get the hang of it you'll see it's a
really cool utility.  At one point I rewrote all the Enumerable
methods via #inject just for the learning experience. :-)

Kind regards

robert