From: gabriele renzi Date: 2004-04-23T22:54:05+09:00 Subject: Re: [NEWBIE] Extract all occurences from a text il Fri, 23 Apr 2004 15:43:24 +0200, Kristof Bastiaensen ha scritto:: >On Fri, 23 Apr 2004 05:08:00 -0700, David Alan Black wrote: > >>> >>> you could simply do: >>> >>> lines=[] > >This line has no effect, the Array will be discarded >at the next expression > >>> open(filename) do |f| >>> lines= f.grep your_regexp >>> end >> just try it ;P If you do not initialize a variable outside of a block it will be discarded when the block ends. This will change in ruby2 and work like you expect (I expect the behaviour it has ATM)