From: Mohammad Khan Date: 2004-10-14T00:19:47+09:00 Subject: Re: Sharing variables across methods On Wed, 2004-10-13 at 11:08, David Garamond 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: > > $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? How about to keep all your methods in a module or class. And use accessors. -- Mohammad Khan Legal Computer Solutions, Inc.