Mohammad Khan wrote: >>When writing short scripts (several pages long) I often want to share >>some variables (like CGI object, DB connection object) in several >>methods. I often use globals for this: >> >>When I don't want to see all those dollar signs, I use a wrapper method: >> >> $_cgi = CGI.new('html3') >> def cgi; $_cgi end >> >> def foo >> cgi.out { ... } >> end >> >>But it still looks ugly to me. Any suggestion to make it more elegant? > > How about to keep all your methods in a module or class. > And use accessors. I should stress that this is for *short* scripts :-) I don't want to define any module or class like I would have to in Java. But yes, in a class I would just use attr_{reader|accessor}. -- dave