On Fri, 17 Dec 2004, Paul Johnson wrote: > On Fri, Dec 17, 2004 at 09:17:05AM -0500, Chris Devers wrote: > > > On Thu, 16 Dec 2004, Charles K. Clarkson wrote: > > > > > Don't declare all your variables at the beginning > > > of the script. It works in other languages, but not > > > in perl. Declare them as you go. > > I suppose that depends on your definition of "works". > > > Out of curiosity, why this rule? > > Locality of reference.
Meaning... declare it where you use it, QED ? The counterargument to that might be "spagetti code, QED". That is, if you declare everything at the last possible line, then there's no clear organization of what data is being tracked in a given segment of code. On the other hand, if you cluster the declarations a bit -- not globally, but lexically -- then to my thinking things are clearer. This isn't something I feel strongly about one way or the other. I just find it striking that the advice given out on this list differs so starkly with the practice that I have been taught (and have seen other people doing in their code) in the past. -- Chris Devers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>