On Aug 24, 9:37 am, [EMAIL PROTECTED] (Chas Owens) wrote: > On 8/24/07, Paul Lalli <[EMAIL PROTECTED]> wrote: > snip> 'our', like 'my', is lexically scoped. Its effects are terminated > > when the innermost enclosing block ends. So if you're using the same > > package variable in two different blocks, you have to use 'our' in > > each of them: > snip > > Your syntax for 'our' is confusing at best. Just declare it once, at > > the very top of your program. > snip > > Again. Stop using 'our' all over the place. Declare your variables > > once, at the beginning of your program, if it's being used throughout > > the program. > > snip > > I can't say that I agree with the advice to declare all of your our > variables once at the top of your program. To my way of thinking this > defeats the purpose of having the our function*. I have a > once-per-function rule for our; if a function needs to use a global > variable, then it has to request it.
I tend to agree. However, this poster was not using functions. He was simply declaring 'our' every time he saw the variable. That's why I told him to move the declaration of 'our' to the top. The reason he "had to" keep declaring 'our' is that he was only declaring it in the insanely small scope of the actual expression. There is no need for that. Just declare it before the big block of code that uses it. Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/