From: Brian Candler Date: 2003-04-02T00:13:36+09:00 Subject: Re: Opera bookmark cleaner. On Tue, Apr 01, 2003 at 11:44:58PM +0900, Mattia Peronio wrote: > I would like to give my contribution to the ruby community, publishing this simple program (my first ruby program!) which cleans Opera bookmarks from double entries. It works, but use it at your own risk. It also convinced me about the power of ruby. Welcome, and good start! Just one comment: you don't actually need the global variable "$buff". If you want to assign to a local variable within a block, and for it to persist afterwards, you just need to create it outside the block. In other words: buff = nil File.open(filename, "r") { |f| buff = f.gets(nil) } ... answer is in 'buff' However, in this case you could just do buff = File.open(filename, "r").read (or 'readlines' if you want an array of lines instead of one big line) It's one of the joys of Ruby that you keep finding clearer and shorter ways of writing the same thing... in many cases someone has already wanted to do the same thing and written a method to do it :-) Cheers, Brian.