[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]

Re: [ID 20000123.003] [BUG our() 5.005_63] Lexical scoping problems.



Pete Jordan writes:
: Consider a pair of functions that access the same data:
: 
: 	sub shove($) {
: 	  our @stack;
: 	  push @stack, shift;
: 	}
: 
: 	sub prolapse() {
: 	  our @stack;
: 	  pop @stack
: 	}

Or even:

    sub shove($) { push our @stack, shift }
    sub prolapse() { pop our @stack }

Of course, that's not so different from

    sub shove($) { push @MyPackage::stack, shift }
    sub prolapse() { pop @MyPackage::stack }

but with C<our> you don't need to remember your own package name.

Larry


References to:
Pete Jordan <pjordan1@email.mot.com>

[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]