From: Esmail Bonakdarian Date: 2006-10-06T08:35:06+09:00 Subject: Re: 1st program -- how would you improve this? David Vallner wrote: > I'd probably have used OpenURI and then > > text = open('http://www.example.com/').read > which I find a little more readable. ah .. cool .. I got what I had before from some sample code I found either in a book or on line. Lots of ways to do things, hence my query, and goal to find out :-) > Oh, and probably also a HTML parser like Hpricot to make getting the > title tag more foolproof. Some one else had mentioned Hpricot .. but that's an add-on, right? Ie not part of the standard Ruby distribution? My goal is to write code that will run pretty much everywhere w/o special requirements, but I will look into Hpricot since it seems very useful. > I also strongly disapprove of the Perl-ish use of global variables that > get set as a side-effect of a regex match. Notably because that's a) > relying on a side-effect of a function on b) a global variable. But > coding everything explicitly is a personal pet peeve of mine. Oh, I'm all for explicitly coding too .. (ie don't rely on default initial values for variables, always explicitly initialize them myself - good habit in case you work with a language that doesn't do that for you, like C. or use parens etc.) So, by globals, are you referring to the $` and $' ?