"David Garamond" <lists / zara.6.isreserved.com> schrieb im Newsbeitrag news:416D44D5.7050607 / zara.6.isreserved.com... > 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: > > $cgi = CGI.new('html3') > $conn = PGconn.connect(...) > > def foo > $conn.exec(...) > $cgi.out { ... } > end > > 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? Personally I'd leave the globals in (with "$") - using these accessor methods rather obscures what's happening. If you use those accessors then maybe instance variables are more suited. That way you might be able to later migrate the script into a class - which is probably the best thing anyway if it gets more complex (command pattern comes to mind). Kind regards robert